Golang FAQ

What does an underscore in front of an import statement mean? Blank assignments identify code as a work in progress. Or to import a package solely for its side-effects(initialization), use the blank identifier as explicit package name. What is … in Go? A parameter type prefixed with three dots(…) is called a variadic parameter. That means you can pass any number or arguments into that parameter. The function will receive the list of arguments for the parameter as a slice of the type declared for the parameter. »

Golang Method

Go has both functions and methods. In Go, a method is a function that is declared with a receiver. A receiver is a value or a pointer of a named or struct type. All the methods for a given type belong to the type’s method set. Let’s declare a struct type and a method for that type: type User struct { Name string Email string } func (u User) Notify() error First we declare a struct type named User and then we declare a method named Notify with a receiver that accepts a value of type User. »