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
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 PracticeNow the answer time , because gofmt is not optional , as a programmer you must format properly :)
Comments
Post a Comment