2_常见库操作
文件操作
import(
"bufio"
"fmt"
)
// 循环处理kafka消息
path := "./1.json"
file, err := os.Open(path)
if err != nil {
fmt.Println("open file failed")
}
defer file.Close()
scanner := bufio.NewScanner(file)
i := 1
for scanner.Scan() {
i = i+1
fmt.Println("-----", i,scanner.Text( "-----")
}
标签:scanner,fmt,常见,-----,file,path,Println,操作
From: https://www.cnblogs.com/hystill/p/16815563.html