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 :)

No comments:

Post a Comment

Do you support us?

Business address
0x1D24D8f27ea73ff604C7685246bdC6ae55bddaEF

Mighty Roman Empire's trail and err

  The Roman Empire's strength, fuel by economical corridor and best men's for the service but Golden days might be over when corrup...

Achieves