Go is an open-source programming language that makes it easy to build simple, reliable, and efficient software. Go is expressive, concise, clean, and efficient. In addition to this, its concurrency mechanisms make it easy to write programs that get the most out of multicore and networked machines while its novel type system enables flexible and modular program construction. With this in mind, I wanted to write an article that dives into the fundamentals of the Go programming language with the aim of encouraging readers to add this language to their programming repertoire.

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.

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:

package mainimport "fmt"func main() {
	fmt.Println("Hello Medium")
}

Now you can build and install that program with the go tool:

$ go install go-project

This command builds the go-project command, producing an executable binary.

#golang #web-development #programming #go

The Ultimate Beginners Guide to Go
1.75 GEEK