"variable declared and not used" compilation error

You could try this:

cwd, _ := os.Getwd();

but it seems like it would be better to keep the error like in Jurily's answer so you know if something went wrong.


this can make development a bit of a pain. sometimes i run code that has variables declared but not used (but will be used).

in these cases i simple do this:

fmt.Printf("%v %v %v",somevar1,somevar2,somevar3)

and there, they are "used".

i'd like to see a flag to the go tools that lets me suppress this error while developing.