- since 2009
- Open Source @Google
- developed by Ken Thompson, Rob Pike, Robert Griesemer
- mainly influenced by C, C++, C# and Java
- compiled, statically typed
- syntax similar to C / C++ / Java
- fast compilation and execution
- compiles to standalone executables
- no IL / Runtime
- concurrency support in the language (keywords)
- garbage collector
- Hugo
- docker
- kubernetes
- istio
- prometheus
Already more than 40% of Open Source Software is written in Go, according to CNCF OpenSource Software.
package main
import "fmt"
func main () {
fmt.Println("Hello, world!")
}
- https://play.golang.org/
$ go run hello.go
$ go build hello.go
- VS Code with Go tools
- Atom
- GoLand (JetBrains - no Community Edition yet)
- IntelliJ Idea
- OS > JRE > App (→ plattform independent)
- OS > App (→ explicitly build for each platform!)
- no classes, only types
- there are pointers and adresses
- Java controls visibility with keywords, in Go that is done by the first letters casing.
- upper case : public / "exported"
- lower case : private in the package
- exception handling in Java with exceptions; Go has errors as return types and panic for system exit
- Interfaces in Go are implicit. They are implemented, as soon as all methods are implemented
- annotations with tags
receiver:value
- OOP in Go: https://code.egym.de/introduction-to-oop-in-golang-e4841a9c4e3e?gi=ad44d141bffc
- RESTful in Go: https://tutorialedge.net/golang/creating-restful-api-with-golang/
- tests are next to the code, files end with
_test.go
- there are no (built-in) asserts
- test execution with
$ go test .
- coverage:
$ go test -coverprofile=coverage.out .
orgo tool cover -html=coverage.out
Go comes with its own formatter. It is best practice to follow its guidlines and run go fmt
on changed files / folders, before committing.