Golang Bufio Gjson
package main
import (
"bufio"
// "fmt"
"log"
"os"
c "github.com/gookit/color"
"github.com/tidwall/gjson"
)
func main() {
file, err := os.Open("/path/to/file")
if err != nil {
log.Fatal(err)
}
defer file.Close()
scanner := bufio.NewScanner(file)
//! Inrease the buffer capacity if necessary
const maxCapacity = 100 * 1024 // 20GB == 20_000*1024
buf := make([]byte, maxCapacity)
scanner.Buffer(buf, maxCapacity)
// optionally, resize scanner's capacity for lines over 64K, see next example
for scanner.Scan() {
line := scanner.Text()
g := gjson.Parse(line)
for _, r := range g.Array() {
if r.Get("ev").String() == "AM" {
c.Greenln(" ")
}
}
}
if err := scanner.Err(); err != nil {
log.Fatal(err)
}
}
smjure