CategoriesGolang

Let’s GO

Install and download GO by following the link https://golang.org/dl/

Install and download VS Code ( lightweight and free ) or Goland ( requires a licence ) I used both – Goland is a winner as it makes our life much easier.

Let’s write our first boring hello world:

How do we run the code in our project? Navigate to the project directory and type go run filenamewewanttoexecute in this case the file is main.go

What does package main in line 1 mean? A package is a collection of common source code files. There are two types of packages – executable or reusable. In this case, package main creates an executable file when we ran go run main.go. func main() is required with package main.

What does import “fmt” in line 3 mean? https://golang.org/pkg/fmt/ is the name of a standard library package that it is included in the GO programming language by default. By importing means give the package main access for all the code and all the functionality that is contained into the “fmt” package.

What is func main()? func tells GO that we are going to declare a function whereas main is the name of the function. Parameters to a function are passed in ().

Leave a Reply

Your email address will not be published. Required fields are marked *