Wednesday, November 14, 2018

Commands Line Arguments

Today , i will demonstrate how to check command line arguments in GoLang. First of all , you have to answer , why gophers follow gofmt ? You can answer this question below.


package main
import (
              "fmt"
               "os"
)

func main(){
              fmt.Println("command args :" , os.Args[0:])
}

import "os"
              os is most powerful library in go or you can say a core of go. All the low level operation require os library , such as process Id, chown, mkdir, get environment path or set , threads etc. Concurrency also achieved through os libraries . Upcoming post concurrency discuss in detail. https://www.golang-book.com/books/intro/10
os.Args[0:]
              args[0:] slice the array length . Slicing array length or capacity.  Just to remember, that in case of slice is that how much length programmer want to access.
                Examples: 
                 C program we, write this
                        int arr[] ={0,2,3,1,4}
                        int i =0;
                        for (; i < sizeof(arr/2); i++) {
                             // code
                        }
                but in Go
                         int arr[] = {0,2,3,1,4}
                         fmt.println("slice", arr[2:])
                         // easy and simple
                https://tour.golang.org/moretypes/11
Good Practice 
 Now the answer time , because gofmt is not optional , as a programmer you must format properly :)

Install go via terminal

Why programmer just like you use terminal instead of G-U-I? Post your answer below , i like terminal because , it help me to understand what application work. First download file from go official website and follow the instruction and make sure environment set properly.

open terminal and type 
$ go
               go command open go shell , now you can run go program, test, check version etc.
[$ terminal ready to read ]

$go build helloGo.go
               this line compile go program just like c or c++
$./helloGo
               now you can want to see your output
$go run helloGo.go
             this line perform all tasks which build or ./ perform. Tasks such as compile or link the output and also execute the program  
$go version
             go version print version
go version go10.1 linux/amd64



Tuesday, November 13, 2018

Hello-Go

Google developers create a new programming language called GoLang which can change programmer view totally .  Now a days , Programmer have unleash power . Power that only programmer can understand , why? Because no one , who can play beyond rules. Golang language easy simple and powerful. Don't follow me , follow your heart or explore what you want to do .

package main


import(
          " fmt"
)

func main(){
               fmt.Println("Hello World ! Go")
}


package main
                    when a programmer write a standalone application in Go. First programmer tells about standalone program or a library.

import (
            "fmt"
)
               If you work in c language what this line say, if you don't have . Don't worry . It's tells this program require fmt which is used for output or display message.

func 
       Golang provide a way to write a function . Programmer only need func
main 
       As you know all program start from main
 fmt.Println("')
        This is the easiest way to display message on the screen or console.

In next blog , i write how to run a golang program in your terminal, until now you can use
https://play.golang.org/ .

Do you support us?

Business address
0x1D24D8f27ea73ff604C7685246bdC6ae55bddaEF

Kings archives to book stalls 📚

  Through books, we can explore the past, understand the present, and shape the future. Historically, books were treasured by kings and merc...

Achieves