# go文件操作
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( "-----")
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19