Set up golang project

How to setup and use golang


Golang is a programming language developed by Google. It can used to create cloud services, web , CLI tools etc. The first step to use Go is download and install the SDK.

Hello world

After the installation please check the environment variables, make sure the path being added your system.

go version
go env

Now you are ready to stat writing your code. create a simple directory and cd into it.

on the terminal issue the following command to initialize the project module.

go mod init example/helloword 

It will create .mod file which is similar to package.json in Nodejs projects where dependencies listed.

create main.go

This is the entry point to your project. Every go program should start with a main function

//main.go
package main

import  "fmt"
func main(){
fmt.printline('Hello word')
}
 

Run the project

By using go run . or go run main.go can execute the program.

Author: Manoj

Developer and a self-learner, love to work with Reactjs, Angular, Node, Python and C#.Net

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.