In your example, you are repeatedly reading one 'item' from the line. This 
is the source of the confusion, as this is not how Fscanln works - when you 
do this, *each* item is the documented 'final item' after which there must 
be a newline.

That is, your data would look more like this:
space separated column headers
first second third last
some data with the
same pattern of columns

and your read would be pulling all of those items from one line:
fmt.Fscanln(in2,&one,&two,&three,&four)

It is expected/designed to read one line of data at a time, and for you to 
know in advance the number of items in the line, and to expect to receive 
an error if they don't match. It is also expected that each column will 
have a consistent datatype, and for that to match the types of your 
parameters, and to error if the data can't be parsed.

For parsing arbitrary string data, you might be better off just using 
bufio.Scanner with bufio.ScanWords.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/golang-nuts/d13f4b65-3161-43bf-b83e-a04be58d2059n%40googlegroups.com.

Reply via email to