Top "Go" questions

Go is an open-source programming language.

How to search for an element in a golang slice

I have a slice of structs. type Config struct { Key string Value string } // I form a slice of the above …

go struct slice
How to compare if two structs, slices or maps are equal?

I want to check if two structs, slices and maps are equal. But I'm running into problems with the following …

go go-reflect
How to stop a goroutine

I have a goroutine that calls a method, and passes returned value on a channel: ch := make(chan int, 100) go …

go goroutine channels
Setting HTTP headers

I'm trying to set a header in my Go web server. I'm using gorilla/mux and net/http packages. I'd …

http go cors http-headers
Convert Go map to json

I tried to convert my Go map to a json string with encoding/json Marshal, but it resulted in a …

json go
Is there a method to generate a UUID with go language

I have code that looks like this: u := make([]byte, 16) _, err := rand.Read(u) if err != nil { return } u[8] = (u[8] | 0…

go uuid
"unrecognized import path" with go get

I'm trying to install a web.go, but running go get github.com/hoisie/web returns package bufio: unrecognized import …

go installation
Sort Go map values by keys

When iterating through the returned map in the code, returned by the topic function, the keys are not appearing in …

go hashmap
How to read a text file?

I'm trying to read "file.txt" and put the contents into a variable using Golang. Here is what I've tried... …

go
How to write log to file

I'm trying to write to a log file with Go. I have tried several approaches, all of which have failed. …

go logging