Golang Code Examples

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

🧑‍🤝‍🧑 Copy a slice in Go

Learn how to make a deep copy of a slice
introduction slice

🧮 Sort a string slice containing numbers in Go

Learn how to sort strings with numbers in natural order
sort slice strings

🗂️ Introduction to SQLite in Go

Learn how to create SQLite repository and make basic operations
db sql sqlite

🔎 Check if the slice contains the given value in Go

Learn how to write a function that checks if a slice has a specific value
introduction slice

🍒 Concatenate strings in Go

Learn the differences between string concatenation methods
introduction strings

🔌 Handle 'connection reset by peer' error in Go

Learn what it means and how to detect the 'connection reset by peer' error
http errors

👈 Decode Base64 to a string in Go

Learn how to decode Base64 data to a string using encoding/base64 package
base64 encoding strings

👉 Encode a string to Base64 in Go

Learn how to encode strings to Base64 using encoding/base64 package
base64 encoding strings

🖨️ Convert string to []byte or []byte to string in Go

Learn the difference between a string and a byte slice
introduction strings slice

🧠 Print the memory address of a variable in Go

Learn how to find and print the address of a variable or pointer
introduction pointer slice
1 ... 6