Top "Go" questions

Go is an open-source programming language.

How to set headers in http get request?

I'm doing a simple http GET in Go: client := &http.Client{} req, _ := http.NewRequest("GET", url, nil) res, _ := client.…

http go
How to trim leading and trailing white spaces of a string?

Which is the effective way to trim the leading and trailing white spaces of string variable in Go?

go
How to print the values of slices

I want to see the values which are in the slice. How can I print them? projects []Project

arrays go
How to properly seed random number generator

I am trying to generate a random string in Go and here is the code I have written so far: …

random go
Gmail: 530 5.5.1 Authentication Required. Learn more at

This Go program successfully sends email from my home computer, but on a virtual server on DigitalOcean receives the following …

smtp gmail go smtp-auth
How to do a https request with bad certificate?

Say I want to get https://golang.org programatically. Currently golang.org (ssl) has a bad certificate which is issued …

ssl https go
How to declare a constant map in Golang?

I am trying to declare to constant in Go, but it is throwing an error. Could anyone please help me …

go
How can I read a whole file into a string variable

I have lots of small files, I don't want to read them line by line. Is there a function in …

string file go
How to check a channel is closed or not without reading it?

This is a good example of workers & controller mode in Go written by @Jimt, in answer to "Is there …

go channel
Read text file into string array (and write)

The ability to read (and write) a text file into and out of a string array is I believe a …

go