3 ms·
You need a little more than that, unfortunately. A quick example: the standard library `flag` package lets you parse command line arguments, and returns either
by kibibu 13y ago
You need a little more than that, unfortunately.
A quick example: the standard library `flag` package lets you parse command line arguments, and returns either pointers or values. You need to know which is which. It's easy, for example, to do this:
var filename = flag.String("file", "default.txt", "file to open")
fmt.Println("Using file ", filename)
The above code looks ok at first glance, but prints the address of filename rather than its value. It can be fixed by using `flag.StringVal` instead of `flag.String`, or dereferencing `filename` using `* filename` in the Println.
So I would say you need to know way less about pointers than C but you still need to know the difference.
http://golang.org/pkg/flag/ http://golang.org/pkg/flag/