I am writing a simple csv file parser in go and cannot find out why I get "undefined: csvfile" and "undefined: err" with the following code. From all of the examples it appears to be correct.
var source string
flag.StringVar(&source, "file", "test.csv", "the file to parse")
flag.Parse()
csvfile, err = os.Open(source)
Use :=
, not =
, to create new variables:
csvfile, err := os.Open(source)