Last active
January 12, 2019 12:13
-
-
Save ivanzoid/5bb6decea3591cd81d3636e65b71ee54 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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