Top "Go" questions

Go is an open-source programming language.

How to print struct variables in console?

How can I print (in the console) the Id, Title, Name, etc. of this struct in Golang? type Project struct { …

struct go
Reading a file line by line in Go

I'm unable to find file.ReadLine function in Go. I can figure out how to quickly write one, but I …

string file parsing go line
What is an idiomatic way of representing enums in Go?

I'm trying to represent a simplified chromosome, which consists of N bases, each of which can only be one of {…

enums go genetics
Concatenate two slices in Go

I'm trying to combine the slice [1, 2] and the slice [3, 4]. How can I do this in Go? I tried: append([]int{1,2}, []…

go append slice variadic-functions
How to read from standard input in the console?

I would like to read standard input from the command line, but my attempts have ended with the program exiting …

go
Contains method for a slice

Is there anything similar to a slice.contains(object) method in Go without having to do a search through each …

go slice
How can I install a package with go get?

I want to install packages from github to my gopath, I have tried this: go get github.com:capotej/groupcache-db-experiment.…

github go
Iterating over all the keys of a map

Is there a way to get a list of all the keys in a Go language map? The number of …

loops dictionary go
Handling JSON Post Request in Go

So I have the following, which seems incredibly hacky, and I've been thinking to myself that Go has better designed …

json go
How do you write multiline strings in Go?

Does Go have anything similar to Python's multiline strings: """line 1 line 2 line 3""" If not, what is the preferred way of …

string go multiline