Created
December 26, 2019 06:29
-
-
Save MohiuddinAkib/b66a97f04f95e46b6f0304e7ca40e564 to your computer and use it in GitHub Desktop.
Scan user input in go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func main() { | |
var line string | |
scanner := bufio.NewScanner(os.Stdin) | |
for scanner.Scan() { | |
line = scanner.Text() | |
fmt.Println("Got line:", line) | |
for _, x := range strings.Fields(line) { | |
fmt.Println("next field: ",x) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment