Monday, May 14, 2018

A Tour Of Go

Hi All,

Today I'm going to introduce a nice tool which you can use to learn Golang, it's called "A Tour Of Go". This tool is available in both online and offline. Following is the link for the online version.



Let see how to use offline version,

After you install Golang on your PC, you can run the following command to open "A Tour Of Go"

go tool tour



Saturday, May 12, 2018

Test your Golang installation is up & running

Hi All,

Today we are going to make simple "Hello World" program to make sure our Golang installation is up and running.

Open your terminal and go to hello folder we make in the last lesson, for me it's,

cd /workspace/go/src/github.com/nisalsp9/hello

After you went there open your text editor I'm going to use gedit, following is the command,

gedit

Now your gedit will open copy and paste following code, 


package main

import "fmt"

func main() {
    fmt.Printf("hello, world\n")

}

Note:  Don't worry about all those syntaxes I will teach you about them in upcoming posts,

Now save your code using hello.go as the file name.

Okay, let's compile ( build ) your code by using the following command,

go build


  Now let's run the hello world program, following is the command,

./hello



See you guys in my next post, bye !!!!!!

Monday, March 26, 2018

How To Install Golang

Hi All,

In this post, I will teach you how to install Golang on your PC, currently, I'm working on Ubuntu OS  I will show you how to install Golang on Ubuntu OS first.

Go to the following link,

https://golang.org/dl/

Then download Golang according to your OS I'm on Ubuntu so I'm going to download Linux one from here,



After your download is finished you have to go to where your download file is placed and then extract it into /usr/local creating Go tree /usr/local/go. Use the following command as sudo.  

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


Now we have to set /usr/local/go/bin to the PATH environment variable. Use the following command to open bashrc via Vim text editor or use any text editor. 

sudo vim ~/.bashrc

Then add the following line to bottom of the file,

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


Let's create a workplace for Go and test our installation is working or not by using a sample code.

Go to your home by using the following command,

cd /home/username/

Then create directory call workplace using the following command,  

mkdir workplace

Then go inside that created directory and create directory call go,

mkdir go

Then go inside that created directory and create directory call src,

mkdir src

We will use GitHub for later in our projects so let's create github.com directory inside the src directory,

mkdir github.com

Then inside the github.com directory make a directory with your Github username.

mkdir yourusername


Following is my workspace path,

workspace/go/src/github.com/nisalsp9/


Let's create our first project directory, go inside your GitHub username directory and make the following directory,

mkdir hello    


Before we start our test project we have to set GOPATH to our workspace, open bashrc add following lines to the bottom of the file.

export GOPATH="/home/nisalsp9/workspace/go"
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
export GOROOT=/usr/local/go

After you add above line you have to source the bashrc file use following command to do that,

source ~/.bashrc 


We will create a hello world program in our next post and test our installation is working, bye ..!

Following are references to Golang installation in different OSs,





How To Write Go Code

Hi All,

At first place, I would like to apologize not to write a post for ages, From today onwards I will post once or twice a week.

In this blog Go What? Why? How? I have written simple posts about What is Golang and Why we use Golang. From today onwards I will write posts about How to write Go Codes.

For ease of both teaching and learning, I will  upcoming posts mainly into three parts,

  1. Programming Fundamentals. 
  2. Advanced Programming. 
  3. Create Golang based web project with MySQL database.

See you guys in my next post. bye....! 

Sunday, September 18, 2016

Why GO ?

Hi All...!

In this post I'm going to show you guys why we have to use GO programming language instead of other programming languages.

“Go will be the server language of the future.” - Tobias Lütke, Shopify

Go is great:

  • Open-source
  • Go is a relatively simple language, easy to read and easy to learn.
  • Go has builtin support for safe multicore programming.
  • Go compiles quickly.
  • Go runs relatively fast.
  • Go is cross-platform.
  • Pure Go programs are standalone, and can run without requiring any other software packages to be installed.
  • Go is statically typed.
  • The standard library is well-documented and consistent.

I think these things are enough for now we will discuss more complex advantages later.

Saturday, September 17, 2016

The Origin of GO

Hi All...!

Let's take a look at the origin of the GO programming language. Like humans and other biological species programming languages also have ancestors. GO programming language inherits most of it's expression syntax, control-flow statements, basic data types, call-by-value parameter passing, pointers from C.

Go is sometimes described as a C-like language or as C for the 21st century

The figure below shows the most important influences of earlier programming languages on the design of Go


Friday, September 16, 2016

What is GO

Hi All...!

In this post I'm going to give you an idea about what is GO programming language.

What is GO ?


Go is an open source programming language that makes it easy to build simple, reliable and efficient software. (From the Go web sit e at golang.org)

Go is a general purpose programming language with advanced features and a clean syntax. Because of its wide availability on a variety of platforms, its robust well-documented common library, and its focus on good software engineering principles, Go is an ideal language to learn as your first programming language.

Go language initially developed at Google in year 2007 by Robert Griesemer, Rob Pike, and Ken Thompson and was announced in November 2009.

Go programming language is a statically-typed language with 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.