GoLang is an open-source programming language developed at Google by Robert Griesemer, Rob Pike and Ken Thompson. It’s statically typed, compiled programming language and syntactically similar to C, but with memory safety, garbage collection, structural typing, and CSP-style(Communicating Sequential Processes) concurrency. Due to architectural advantage, GoLang can be both used for System Programming as well as Web similar to Python. Nowadays GoLang is under comparison with Python for different use cases.

Now we will try to learn some basics of GoLang so that we can get started with our journey with GoLang.

01. Define Package: With “package” keyword we can define packages in GoLang. Make sure you have a “main” package in your file for GoLang to execute the program.

package main

02. Import Packages: In GoLang we can use several notations to import packages as follows

// Notation: 1
import "fmt"
import "math"

// Notation: 2
import (
     "fmt"
     "math"
)

03. Define Basic Functions: GoLang program execution always starts from “main” function inside “main” package file, all other functions should be invoked from that.

// test.go
package main

import "fmt"

func test() {
    fmt.Println("This is a test function for GoLang");
}
func main() {
    fmt.Println("Hello World")
    test()
}

Run your first GoLang Program: You can simply type “go run filename.go” to run and check as follows:

Program Output