Horje
golang bufio gjson Code Example
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)
	}
}




Go

Related
go if Code Example go if Code Example
visual studio code go Code Example visual studio code go Code Example
random string go Code Example random string go Code Example
visual studio code gopath Code Example visual studio code gopath Code Example
gogoanime Code Example gogoanime Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7