\

Get Started With Go Programming Language

Go Programming Language

In this tutorial, we will be started with Go Programming Language which is been developed by Google developers team. So let’s get into it.


Download The New GO Programming Application On Your PC.



What Is Go?

There are three terms in Go Programming Language.

  1. Compiled
  2. Garbage Collected
  3. Concurrent

And these are just the computer science terms which we used to describe the programming language.

1: Compiled

When we say the programming language is compiled, it means that code is been officially adapted to the machine at which it is running on. Usually Compiled languages are going to be more efficient and have better performance. We have heard that the C & C++ these are the two compiled languages, That is similar to GO in their respect.

2: Garbage Collected

Go is garbage collected. In Go, we don’t have to manage memory as a programmer. All program you required memory to operate but some programming languages require you as a developer to expertly manage the allocation of that memory and releasing of that memory. But in Go, the run times handles that for you. so you don’t have to be concerned with that as a programmer.

3: Concurrent

Finally, Go is Concurrent. The concurrence refers to the ability to do more than one thing at a time. In many programming languages for example like C++ or JAVA, concurrency is possible in that programming language, But it tagged on it, it’s not the part of the programming language itself. Within Go, it is built directly into the language. So you have the ability to do more than one thing at a time using basic language construct Because Go is designed concurrency inline

What’s Make GO Different?

  • Efficient like a static language, ease of use like a dynamic language.
  • Type-safe And Memory Safe.
  • Latency-free garbage collection.
  • FAST compile times
Ratings of GO programming language

Go Programming Language - Ratings

Installation

 

Go Get Go!

As if you are interested in developing with Go Programming. So We will First Download the Go programming application.

Link:- https://www.golang.org/dl/
Go Programming Language - download

Imports

Go Programming Language - import

 

The Imports are the way you import or utilize the package in your code. So we have to define some packages, perhaps if we put our code into the packages, and if you want to utilize that package inside our GO code we can reference some other code that inside a package by using this import statement.

GO Workspace

We have to set the workspace for our GO Projects. The first thing you going to is run the command pad. You will head up to your user directory.


C:\Users\rehmaanali> mkdir goWorkspace

C:\Users\rehmaanali> cd goWorkspace

C:\Users\rehmaanali\goWorkspace> echo %GOROOT%
%GOROOT%

As you can see above we have created the directory for our workspace and set the GOROOT path. The next thing we do is set an environment variable.

So open up you control panel then go
Control-Panel \ System and Security \ System
Click the Advance System Setting (Small window will popup)
Click Environment variable
Click Add New
Then

Go Programming Language - enviroment

 

After that, we will create a file by typing command i.e echo %GOPATH%. which we have set the environment variable for PC. Restart the command pad


C:\Users\rehmaanali> echo %GOPATH%

C:\Users\rehmaanali> cd goWorkspace

C:\Users\rehmaanali\goWorkspace> mkdir src

C:\Users\rehmaanali\goWorkspace> cd src

C:\Users\rehmaanali\goWorkspace\src> notepad hello_world.go #open the notepad with file name` 

we have created a new directory and in that, we will store our GO programs.

Go with Hello World!

At the end lets see the basic hello world program in ‘Go’ Programming language.

hello_world.go

package main

import "fmt"
func main(){
   fmt.Println("Hello World, Let's Code GO!");
}

As you can see the name of the file named as hello_world.go, GO programs are saved with the extension ‘.go’

Jump back to the code, as you can see we have declared package main, where main is the entry point for the program to execute. Also, we have to import the ‘fmt’ library which comes by default by the GO.

WRONG METHOD

// THIS WILL BE INVALID - BARCES MUST DECLARE AFTER FUNCTION ONLY
func main()
{
   // 'p' must be capitable - it's Case sensetive.
   fmt.println("Hello World, Let's Code GO!");
}

The above program is invalid, after declaring the function, the braces must be declared after it, or the will be invalid.

 

Run The Go!

After completing the GO code, we can run the GO program in Command Prompt by just typing one command and that is:


C:\Users\rehmaanali\goWorkspace\src> go run hello.go
Hello World, Let's Code GO!  #output


Get Some More GO Programming Here!

About This Author

Hi This Is Rehmaanali. Blogging Is Just A Hobby. Graduate In Bsc Computer Science

Post A Reply