Golang Code Examples

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

✋ Limit read bytes using io.LimitedReader in Go

Learn how to read a specific number of bytes from io.Reader
io

♾️ Infinite loop in Go

Learn how to define a "while true" loop
introduction loop

📔 Convert a struct to io.Reader in Go

Learn how to convert a struct to io.Reader and send it as an HTTP POST request body
introduction http

📟 Convert HTTP response io.ReadCloser to string in Go

Learn how to convert a HTTP client response body to string
introduction http

🧑‍🤝‍🧑 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

🗂️ Introductory tutorial 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
1 ... 6