I'm new to golang and using ioutil.ReadFile(os.Args[1])
to fetch a file path from the cli and then processing each line using:
package main
import (
"bufio"
"fmt"
"log"
"os"
)
func main() {
file, err := os.Open(os.Args[1])
if err != nil {
log.Fatal(err)
}
defer file.Close()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
fmt.Println(scanner.Text())
}
if err := scanner.Err(); err != nil {
log.Fatal(err)
}
}
Now I can get the output at stdout. But also get the following ERROR in the end:
msg:"BRUMBRUM";reference:cve,CVE-2007-2810;reference:blah;
msg:"WAKANDA";reference:cve,CVE-2007-2810;reference:blah; file name too long
exit status 1
My file path input is data/srulz.tcl
. FYI, the error message is not a part of the text file.
I need to know where is this going wrong here and how can this be improved?
UPDATE:
Provided issue reproducible code.
Go-ing with flag pkg for now until this mystery is solved