Zgo
  • 2024-06-12Zgo - Writing to a file
     packagemainimport("bufio""fmt""io""os")funcmain(){buffer:=[]byte("Datatowrite\n")f1,err:=os.Create("f1.txt")iferr!=nil{fmt.Pri
  • 2024-06-12Zgo - Read Files
     packagemainimport("bufio""fmt""io""os")funclineByLine(filestring)error{f,err:=os.Open(file)iferr!=nil{returnerr}deferf.Close()r:=bufio.
  • 2024-06-11Zgo - maps
     packagemainimport("fmt""maps")funcdelete(kstring,vint)bool{returnv%2!=0}funcequal(v1int,v2float64)bool{returnfloat64(v1)==v2}funcmain(){m:=map[string]int{"one
  • 2024-06-11Zgo - slices
     packagemainimport("fmt""slices")funcmain(){s1:=[]int{1,2,-1,-2}s2:=slices.Clone(s1)fmt.Printf("%p\n",s1)fmt.Printf("%p\n",s2)s1[2]=0s1[3]=0s1
  • 2024-06-10Zgo - randInt, randString
     packagemainimport("fmt""math/rand""strings")const(//AsweonlywanttogetprintableASCIIcharacters,welimittherangeofpseudo-randomnumbers//thatcanbegenerated.Thetotalnumber
  • 2024-06-10Zgo - stats.go
     packagemainimport("fmt""math""os""slices""strconv")funcmain(){args:=os.Argsiflen(args)==1{fmt.Println("Needoneormorearguments!")
  • 2024-06-10Zgo - which.go
     packagemainimport("fmt""os""path/filepath")funcmain(){args:=os.Argsiflen(args)==1{fmt.Println("Pleaseprovideanargument!")return}file:=args