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.

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 main

import "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.

#go #guid #google #golang

The Ultimate Golang Guide in 2020 for Beginners
6.90 GEEK