Skip to content

Instantly share code, notes, and snippets.

@cuongld2
Last active November 10, 2020 03:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cuongld2/bfbb1001520f9e96d153738f09f53faa to your computer and use it in GitHub Desktop.
Save cuongld2/bfbb1001520f9e96d153738f09f53faa to your computer and use it in GitHub Desktop.
Scan line maxCapacity
scanner := bufio.NewScanner(file)
const maxCapacity = 512*1024
buf := make([]byte, maxCapacity)
scanner.Buffer(buf, maxCapacity)
// The bufio.ScanLines is used as an
// input to the method bufio.Scanner.Split()
// and then the scanning forwards to each
// new line using the bufio.Scanner.Scan()
// method.
scanner.Split(bufio.ScanLines)
for scanner.Scan() {
if strings.Contains(scanner.Text(),geneBackupSymbol){
i +=1
data = append(data, []byte(scanner.Text())...)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment