~/learning-go/01-golang-notes.md · 2022-10-16

Golang notes

Taking notes while learning Go.

Introduction

Installing the Go environment has never been easier: download the executable, run it, and you have a working installation.

Go is an open source programming language from Google, originally developed for Google’s own needs — large codebases, many engineers, slow builds.

First program

Every Go program starts in package main, with a main function as the entry point. The fmt package (short for formatting) handles input and output.

hello.go
package main

import "fmt"

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

Run it directly with go run hello.go, or compile a binary with go build.

golang