Questions tagged [go]

Go is an open-source programming language, with a syntax loosely derived from C. It's statically typed, with limited dynamic typing capabilities; it also features automatic memory management, built-in concurrency primitives, variable-length arrays – called slices –, and a large standard library.

Go (sometimes "Golang" for search-ability) is a general-purpose programming language. While originally created by Google, Go is an open source project with a large contributor base. It aims to be efficient both for development and execution with a focus on fast compilation and increased maintainability of large projects. Go was originally targeted at systems programming tasks such as building server/web applications, high throughput middleware, and databases, but it has a growing ecosystem of libraries allowing it to be used for a wide variety of tasks such as developing end-user daemons, CLIs, and desktop/mobile applications.

The first class concurrency mechanisms of Go make it easier to write programs that get the most out of multicore and networked machines, while its structural type system enables flexible and modular program construction. Go compiles quickly to memory safe machine code yet has the convenience of garbage collection and the power of run-time reflection. It's a fast, statically typed, compiled language that develops like a dynamically typed, interpreted language, but performs like native code.

Go Reference Documentation

Go Tutorials

Go Books (Paid)

Go Books (Free)

Popular Go Projects

Go Mailing Lists

Go chat

Online Go Compilers

Go FAQ

Go Code Editors & IDEs

Go Dependency Management

Go2 Resources

Go2 is an umbrella term used to indicate language changes under discussion that may break Go's compatibility promise. Even if a feature ends up being suited for a Go 1.x release, it is still often tagged and referred to as Go2. This includes proposals, draft specifications, dev implementations, etc.

70688 questions
29
votes
5 answers

Algorithm for finding the color between two others - in the colorspace of painted colors

When mixing blue and yellow paint, the result is some sort of green. I have two rgb colors: blue = (0, 0, 255) and yellow = (255, 255, 0) What is the algorithm for finding the rgb color that is the result of mixing the two colors, as they would…
Alexander
  • 9,737
  • 4
  • 53
  • 59
29
votes
1 answer

not compatible with reflect.StructTag.Get

I was working in Google CLoud and all was fine.. but when I clone all my project in my PC, I have this messages in every JSON struct. struct field tag bson:"edad" json:"edad, omitempty" not compatible with reflect.StructTag.Get: suspicious space in…
Elba Nanero
  • 507
  • 1
  • 4
  • 10
29
votes
4 answers

How to show the entire value in VSCode debug mode

I have been having trouble seeing the entire value of variables while debugging in Go. When I click on a rather long value, it shows me ... +# more. But I can't find a way to see the rest of that value. Even in watch mode it does the same thing,…
coloradoman
  • 341
  • 1
  • 5
  • 11
29
votes
7 answers

go modules installing go tools

I'm using go modules as dependency management, and I'm having problem to install something like this: go get -u github.com/go-critic/go-critic/... the result from above was: go: cannot find main module; see 'go help modules'
Luis.at.code
  • 299
  • 1
  • 3
  • 6
29
votes
5 answers

How to stop GoLand from auto removal of unused imports?

I am working with JetBrains GoLand and wondering if it's possible to somehow disable the auto removal of unused imports. I have searched the JetBrains forums earlier and there is no such information specifically for Goland.
nombreinvicto
  • 451
  • 1
  • 4
  • 6
29
votes
3 answers

How to pass type to function argument in Go

ERROR: type CustomStruct is not an expression. type CustomStruct struct { } func getTypeName(t interface{}) string { rt := reflect.TypeOf(t).Elem() return rt.Name() } getTypeName(CustomStruct) How can I pass struct type to function…
Lion.k
  • 2,519
  • 8
  • 28
  • 43
29
votes
3 answers

How to test if a goroutine has been called while unit testing in Golang?

suppose that we have a method like this: func method(intr MyInterface) { go intr.exec() } In unit testing method, we want to assert that inter.exec has been called once and only once; so we can mock it with another mock struct in tests, which…
sazary
  • 906
  • 1
  • 9
  • 20
29
votes
1 answer

How do you name a multi-term package in golang?

Naming conventions for go packages are well-documented, with golang.org's blog stating: Good package names are short and clear. They are lower case, with no under_scores or mixedCaps. They are often simple nouns, such as [descriptions removed]:…
TheEnvironmentalist
  • 2,694
  • 2
  • 19
  • 46
29
votes
4 answers

Unmarshal map[string]DynamoDBAttributeValue into a struct

I'm trying to set-up an AWS-lambda using aws-sdk-go that is triggered whenever a new user is added to a certain dynamodb table. Everything is working just fine but I can't find a way to unmarshal a map map[string]DynamoDBAttributeValue like: { …
AndreaM16
  • 3,917
  • 4
  • 35
  • 74
29
votes
6 answers

How do you remove the first character of a string?

What is the suggested method to remove the first character of a string? I've looked through the documentation for string methods but I don't see anything that works like javascript's String.slice().
Quentin Gibson
  • 442
  • 1
  • 5
  • 15
29
votes
2 answers

Golang doc func parameters

Reading the godoc doc. It does not specify how function parameters are documented. What is the reason for omitting this?
Justin Lin
  • 673
  • 1
  • 6
  • 15
29
votes
2 answers

How to add URL query parameters to HTTP GET request?

I am trying to add a query parameter to a HTTP GET request but somehow methods pointed out on SO (e.g. here) don't work. I have the following piece of code: package main import ( "fmt" "log" "net/http" ) func main() { req, err :=…
Patryk
  • 22,602
  • 44
  • 128
  • 244
29
votes
3 answers

How to obtain all request headers in Go

How can I obtain all available http headers from a request as array in Go? I see only the following two methods: Header(name string, value string) GetHeader(name string) But in this case I need to know the name of the Header and can't return all…
botscripter
  • 805
  • 2
  • 11
  • 21
29
votes
2 answers

Golang HTTP x509: certificate signed by unknown authority error

I am creating a client app using Golang 1.9.2 and I am having some trouble to access my backend. The thing is that my app is working fine in the latest versions of Windows and Linux, however when I run it on Windows XP (yes, unfortunately I do have…
Felipe
  • 6,312
  • 11
  • 52
  • 70
29
votes
4 answers

Is there a difference in Go between a counter using atomic operations and one using a mutex?

I have seen some discussion lately about whether there is a difference between a counter implemented using atomic increment/load, and one using a mutex to synchronise increment/load. Are the following counter implementations functionally…
Hugh
  • 1,171
  • 1
  • 11
  • 15