Solution 4: Telling a UNIX System What to Do
Let’s solve the challenges set in the previous lesson.
We'll cover the following...
Solution 1
Here’s the modified byLine.go code that uses Scanner instead of ReadString('\n'):
Dimitris,Tsoukalos,2101112223,1600665563 Mihalis,Tsoukalos,2109416471,1600665563 Jane,Doe,0800123456,1608559903
byLine.go
Code explanation
Line 16: This creates a new
Scannerusingbufio.NewScanner(f), wherefis the file we opened earlier.Lines 17–19: We ...
Ask