wiki/articles/golang.md
tocariimaa cb69c5d301 rewrite articles urls, once again
change the html extension to md
2025-02-08 21:29:57 -03:00

1.4 KiB

Go

Go (also Golang) is a compiled programming language created by Rob Pike, Ken Thompson and others at Google, released in 2009. In contrast with other "modern" languages (such as Rust, etc.) Go is relatively simple, with the spec being about 130 pages.

Go generated executables are bloated (>1 MiB), since everything is statically linked. Using flags like -ldflags "-s -w" can aid with the executable size by stripping debug symbols, but getting it under 1 MiB is almost impossible with the default compiler. However, alternative implementations such as TinyGo compile to small executables, mainly targeted for embedded use.

Furthermore, Go's runtime is quite heavy by having a garbage collector and a weird stack layout for supporting the builtin concurrency system, goroutines, which makes C interop slow and cumbersome compared to other languages.

Go being a Google project, depends on it financially, also it has a code of censorship.

Compilers

Due to Go having a formal spec (and being simple enough), Go has more than one compiler:

  • The main compiler, written in Go itself. { no idea if it has a name ~tocariimaa }
  • gccgo: GNU Compiler Collection's Go compiler
  • TinyGo: targeted at embedded systems.

Examples

Hello world

package main

import "fmt"

func main() {
    fmt.Println("Hello, world!")
}

Compiling and running:

go run hello.go