Skip to content

Instantly share code, notes, and snippets.

@ivanzoid
Last active January 12, 2019 12:13
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 ivanzoid/5bb6decea3591cd81d3636e65b71ee54 to your computer and use it in GitHub Desktop.
Save ivanzoid/5bb6decea3591cd81d3636e65b71ee54 to your computer and use it in GitHub Desktop.
package main
import (
"bufio"
"log"
"os"
"strings"
)
func main() {
if len(os.Args) <= 1 {
return
}
file, err := os.Open(os.Args[1])
if err != nil {
log.Fatal(err)
}
defer file.Close()
processFile(file, processLine)
}
func processFile(file *os.File, processLine func(comps []string)) error {
scanner := bufio.NewScanner(file)
first := true
for scanner.Scan() {
if first {
first = false
continue
}
line := scanner.Text()
comps := strings.Split(line, "\t")
processLine(comps)
}
if err := scanner.Err(); err != nil {
return err
}
return nil
}
func processLine(comps []string) {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment