Cookies management by TermsFeed Cookie Consent
Russia has invaded Ukraine and already killed tens of thousands of civilians, with many more raped or tortured. It's a genocide. We need your help. Let's fight back against the Russian regime.
Help Ukraine! Fight the Russian regime!

Go Code Examples

Learn Go programming by example. GOSAMPLES is a library of Go code snippets that let you solve everyday code problems.

Please consider supporting us by disabling your ad blocker

โณ Time difference between two dates in Go

shorts time

๐Ÿ‘€ Get a hostname (domain) from a URL in Go

shorts url

๐Ÿ–– Calculate Median in Go using Generics

Learn how to find "the middle value" of a slice
numbers math generics generics-intro

๐Ÿ‹๏ธโ€โ™‚๏ธ Calculate the power of a number x^y in Go

shorts numbers math

๐Ÿค Calculate arithmetic mean in Go using Generics

Learn how to calculate mean for a slice of any numeric type
numbers math generics generics-intro

๐Ÿšง Remove non-printable characters from a string in Go

Learn how to remove invisible characters from a string

๐Ÿค Create a new file in Go

shorts introduction file

๐Ÿงน Delete or remove a file in Go

shorts introduction file

๐Ÿฆฅ Ternary operator in Go

Learn how to substitute a ternary operator not available in Go
introduction syntax

โœŒ๏ธ 4 ways to create or print string with double quotes in Go

Learn how to create and print double-quoted string
introduction strings
1 ... 2 ... 10