Tutorial:Google Go Programming Language

Google Go By Sagar Jaybhay

It is an opensource programming language that is developed by Google. It is also known as Golang.

It is a statically compiled language. Features of this language Go supports concurrent programming which allows multiple processes simultaneously.

Where to download a setup file:- https://golang.org/dl/

Tutorial:Google Go Programming Language
Google Go Setup download

Go to this link you will see the Html page looks like in theabove image after this as per your machine os choose which setup you want toinstall. For this tutorial, I m using Windows.

After installing the setup you will see the root folder at C:\Go folder location In windows.

Editor for this we use Visual Code which is free and for you need to install Go plugin for visual studio code. Plugin show in the below image.

Google Go Plugin For Visual Studio Code

Tutorial:Google Go Programming Language
Go Plugin For Visual Studio Code

After this plugin installation, you need below plugin also to successfully code

Addon Plugin For Google Go Language

  •   gocode
  •   gopkgs
  •   go-symbols
  •   guru
  •   gorename
  •   gotests
  •   gomodifytags
  •   impl
  •   fillstruct
  •   goplay
  •   godoctor
  •   dlv
  •   gocode-gomod
  •   godef
  •   goreturns
  •   golint

After installing all this try to code simple hello world program in go. The file extension for this programming language is .go.

First Hello World Program In Google Golang

package main

import "fmt"

func main(){
    fmt.Println("Hello world!!");
}

Tutorial:Google Go Programming Language
Google Go Hello World code in Visual COde

Basic code explanation:

Package main

In Go language source files are organized into systemdirectories called package. In go file first statement must be packagepackage_name. where package_name is the packaged default name for imports. Thefile which you want to reside under the same package gives the same packagename for all files.

The main purpose of the package name is for the reusabilityof code, and you will develop a package as a shared library. When you want todevelop an executable program, you will use a package main. This is for making program executable. This linewhich is package main tells compilerthe package should compile as executable program instead of shared library.

The main function in a program is an entry point of that program it is similar to programming languages like java and C# public static void main.

When you want to build a shared library then you no need to define package main and main function in that program.

Import fmt

The import statement is like import in java and using in c# language. It is used for import package one into another package. In this import fmt the fmt is package name and it comes from go the standard library or inbuilt library. This is used to use the println function. It is like an import static java.lang.System.out; In java language and using System; like c# language.

When you specify import statement in go programming file compiler will look on specified location in environment variable ie GOPATH and GOROOT.

Func main()

As we declared package main at first line then the compiler will look for the main function in our program and we declared a function in the program by using func keyword. In this, we write fmt.PrintLn in this fmt is fmt package and PrintLn is a print function like system.out.println in java and Console.WriteLine in c# language.

GitHub Link:- https://github.com/Sagar-Jaybhay/GoLanguageLab

You may also like...

Leave a Reply

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