Fscan() eats 1st char in scanning values if the values aren't a first value in a line.
The documentation tells: "Fscanln is similar to Fscan, but stops scanning at a newline and after the final
item there must be a newline or EOF."
The test discovers a bug in Fscanln() - https://go.dev/play/p/Jem2lWVn3H5
Result of the test you can see below.
The string for scanning (2 lines below)
Go version go1.22.11 windows/amd64
Build simple, secure, scalable systems with Go
--------------------------------------------------------
| Fscan()
| Fscanln() | Equal |
--------------------------------------------------------
| Go
| Go | true |
| version
| ersion | false - !? |
| go1.22.11
| o1.22.11 | false - !? |
| windows/amd64
| indows/amd64 | false - !? |
| Build
| Build | true |
| simple,
| imple, | false - !? |
| secure,
| ecure, | false
- !? |
| scalable
| calable | false - !? |
| systems
| ystems | false - !? |
| with
| ith | false - !? |
| Go
| o | false - !? |
--------------------------------------------------------
First words in the beginning of every line are equal for Fscan() and Fscanln()
Fscanln() eats a first char in every 2nd, 3rd and other words in any line
Thanks
Ivan
func Fscan
func Fscan(r io.Reader, a ...any) (n int, err error)
Fscan scans text read
from r, storing successive space-separated
values into successive arguments. Newlines count as space.
It returns the
number of items successfully scanned. If that is less than the number of
arguments, err will report why.
func Fscanln
func Fscanln(r io.Reader, a ...any) (n int, err error)
Fscanln is similar to Fscan, but stops scanning at a newline and after the final item there must be a newline or EOF.

> The documentation tells that Fscanln() is similar to Fscan(), my test shows that it isn't true for some cases."similar" does not mean "the same as".Fscanln chomps the fields given, then chomps the next character. If the next character is newline, it's happy. If the next character is not a newline, then it's unhappy and returns an error. At this point, you know the input was bad.No guarantees are made about the state of the input after an error, and as you've found, the next character (which *should* have been a newline) has been chomped.


