Member-only story
Learn the Basics of Programming with Go in 2022
Getting started with a fresh and new programming language in 2021.
Go is an open-source programming language that makes it easy to build simple, reliable, and efficient software. In this article, I’ll make sure you get the fundamentals of the Go Programming Language.
Getting Started
First, we need to install the Go programming language. You can do that by clicking this link.
How to write code for Go
Go programs are organized into packages. A package is a collection of source files in the same directory that are compiled together. Functions, types, variables, and constants defined in one source file are visible to all other source files within the same package.
— How to Write Go Code — The Go Programming Language. https://golang.org/doc/code.html
To compile and run a simple program, choose a module path, and create a ‘go .mod’ file that declares it:
$ mkdir go-project
$ cd go-project
$ go mod init go-project
go: creating new go.mod: module go-project
$ cat go.mod module go-project
$
Next, create a file named app.go inside that directory containing the following Go code: