Get started with Go

Install go on your machine
Some basic programming knowledge
Code editor of your choice
Terminal or Command prompt

1. Create a directory at your Home directory

$ cd
$ mkdir hello

2. Enable dependency tracking for your code

$ go mod init 
go: creating new go.mod

3. Create a file hello.go to write your code in.

$ touch hello.go

4. Copy the following code and Save the file.

package main
import "fmt"
func main() {
     fmt.Println("Hello World!")

Here package main will execute the code as an application.
Function main() is the entry point of the program.
fmt package will provide all functions in that package including Println().

5. Run your code

$ go run hello.go
Hello World! $

Go follows a hierarchical format for storing programs called Workspace.
In your home directory, create a directory go. In that create three directories bin, pkg and src.

$ cd
$ mkdir go
$ cd go/
~/go$ mkdir src pkg bin

Specify the location of workspace in $GOPATH before using it.
src – You will write your code in this directory.
pkg – All the Go package objects will be in this directory.
bin – All executable programs will be in this directory.

also see

C Programming language
Go Programming language
Linked List Array
Simplification Queue
DBMS Reasoning
Aptitude HTML
Previous articleFind the middle of a given linked list in C
Next articleCyclically rotate an array by one in C


Please enter your comment!
Please enter your name here