Go language tutorial

Go language trends in the past 5 year

Go language is a programming language initially developed at Google in the year 2007 by Robert Griesemer, Rob Pike, and Ken Thompson. It is a statically-typed language having syntax similar to that of C. It provides garbage collection, type safety, dynamic-typing capability, many advanced built-in types such as variable length arrays and key-value maps. It also provides a rich standard library. The Go programming language was launched in November 2009 and is used in some of the Google’s production systems.

Audience

This tutorial is designed for software programmers with a need to understand the Go programming language from scratch. This tutorial will give you enough understanding on Go programming language from where you can take yourself to higher levels of expertise.

Prerequisites

Before proceeding with this tutorial, you should have a basic understanding of computer programming terminologies. If you have a good command over C, then it would be quite easy for you to understand the concepts of Go programming and move fast on the learning track.

Features of Go Programming

The most important features of Go programming are listed below −

• Support for environment adopting patterns similar to dynamic languages. For example, type inference (x := 0 is valid declaration of a variable x of type int)

• Compilation time is fast.

• Inbuilt concurrency support: lightweight processes (via go routines), channels, select statement.

• Go programs are simple, concise, and safe.

• Support for Interfaces and Type embedding.

• Production of statically linked native binaries without external dependencies.

The Go Compiler

The source code written in source file is the human readable source for your program. It needs to be compiled and turned into machine language so that your CPU can actually execute the program as per the instructions given. The Go programming language compiler compiles the source code into its final executable program.

Go distribution comes as a binary installable for FreeBSD (release 8 and above), Linux, Mac OS X (Snow Leopard and above), and Windows operating systems with 32-bit (386) and 64-bit (amd64) x86 processor architectures.

The following section explains how to install Go binary distribution on various OS.

Download Go Archive

FDownload the latest version of Go installable archive file from Go Downloads. The following version is used in this tutorial: go1.4.windows-amd64.msi.

It is copied it into C:\>go folder.

OS

Archive name

Windows

go1.4.windows-amd64.msi

Linux

go1.4.linux-amd64.tar.gz

Mac

go1.4.darwin-amd64-osx10.8.pkg

FreeBSD

go1.4.freebsd-amd64.tar.gz

Installation on UNIX/Linux/Mac OS X, and FreeBSD

Extract the download archive into the folder /usr/local, creating a Go tree in /usr/local/go. For example −

tar -C /usr/local -xzf go1.4.linux-amd64.tar.gz

Add /usr/local/go/bin to the PATH environment variable.

OS

Output

Linux

export PATH = $PATH:/usr/local/go/bin

Mac

export PATH = $PATH:/usr/local/go/bin

FreeBSD

export PATH = $PATH:/usr/local/go/bin

Installation on Windows

Use the MSI file and follow the prompts to install the Go tools. By default, the installer uses the Go distribution in c:\Go. The installer should set the c:\Go\bin directory in Window’s PATH environment variable. Restart any open command prompts for the change to take effect.

Verifying the Installation

Create a go file named test.go in C:\>Go_WorkSpace.

One thought on “Go language tutorial

  • January 24, 2018 at 12:48 pm
    Permalink

    Or maybe he liқeѕ bowling.? Lee continuеd. ?I heard somebody say that
    while you hear thunder, that signifies that God
    іs boᴡling inn heaven. I wageer hes really good at it.

    Reply

Leave a Reply

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

%d bloggers like this: