This is a creation in Article, where the information may have evolved or changed.
This article goes from life's Leanote Blog: http://leanote.com/blog/view/531706971a91084358000000
Fmt. SCANLN () does not read a line, but instead encounters a line break and stops,
SCANLN is similar to Scan, but stops scanning at a newline and after the final item there must be a newline or EOF.
As an example:
var I, J, K Intfmt. Scanln (&i, &j, &k) fmt. Println (I, J, K)
Enter 1, 2 return to the car after the program ends. If you switch to FMT. Scan () will also let the input.
Use stdin to read a row of data together with reader:
Reader: = Bufio. Newreader (OS. Stdin) Strbytes, hasmore, err: = Reader. ReadLine ()
But Bufio with FMT. Scan () can have errors together, may be bufio problems, Bufio multiple reads, leading to FMT. Scan () cannot read
or write yourself a way to read a line:
Get a row of Func scanline () string {var c bytevar err Errorvar b []bytefor; err = nil; {_, Err = Fmt. SCANF ("%c", &c) if c! = ' \ n ' {b = append (b, c)} else {break;}} return string (b)}