```go
reader := bufio.NewReader(strReader)
r, _ = reader.ReadString('\n')
//r, _ = reader.ReadString([]byte("\n")[0])
```
第一个报错:cannot use reader.ReadString('\n') (value of type string) as type rune in assignment
第二个报错:cannot use reader.ReadString([]byte("\n")[0]) (value of type string) as type rune in assignment
go版本1.19.3,上面这两种方法不都是没错的吗?
我调用ReadString之前调用了下reader.ReadRune(),后面就不行了,这是什么原理,我重新NewReader一个来ReadString都不行。
#3
更多评论
```go
reader := bufio.NewReader(strings.NewReader("abc\ndgdg\nsdfhdsf"))
//r, _ := reader.ReadString('f')
r, _ := reader.ReadString([]byte("b")[0])
log.Println(r)
```
奇了怪了,换个电脑,同样的版本,就没问题
#1