```
package main
import "fmt"
func main() {
var name string
fmt.Scanln(&name)
fmt.Println(name)
}
```
运行,输入了a b c为什么只获取到了a,有啥好的办法,都是可以获取呢
```
$ go run c2.go
a b c
a
```
## 原因
fmt包的Scan家族扫描的是空格隔开的符号。"The fmt Scan family scan space-separated tokens."
## 解决方案
```go
package main
import (
"bufio"
"fmt"
)
func main() {
var name string
scanner := bufio.NewScanner(os.Stdin)
scanner.Scan()
name := scanner.Text()
fmt.Println(name)
}
```
```go
```
#4