```
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
filename := "go.sum"
fi, err := os.Open(filename)
if err != nil {
panic(err)
}
defer fi.Close()
buf := bufio.NewReader(fi)
for {
line, _, err := buf.ReadLine()
//if err == io.EOF { break }
if err != nil {
panic(err)
}
fmt.Println(string(line))
}
}
```
panic: EOF
goroutine 1 [running]:
main.main()
ReadLine-EOF.go:28 +0x325
exit status 2
有疑问加站长微信联系(非本文作者)