I made a little program for my job that take a file open it and retrieve some informations I need and put them in 2 new files.
I wrote the code on my machine and it works as expected but I'm on Ubuntu and I need to use this tool at work on a windows and it crash.
The filename, directory name or volume label syntax is incorrect.
goroutine 1 [running]:
main.check(...)
C:/Users/GADC/go/Natstar-util/listerDll/main.go:80
main.main()
C:/Users/GADC/go/Natstar-util/listerDll/main.go:18 +0x8d5
exit status 2
Here's my code:
func main() {
reader := bufio.NewReader(os.Stdin)
fmt.Print("Entrez le chemin de votre export: ")
filepath, err := reader.ReadString('
')
check(err)
file, err := os.Open(strings.Split(filepath,"
")[0])
check(err)
defer file.Close()
}
func check(e error) {
if e != nil {
panic(e)
}
}
If someone have an idea to help me, it would be great. Thanks :)
[EDIT] here just the piece of buggy code.
[RESOLVED]
@eryksun was right. The problem was I split my path on ' ' instead of " ".
Now it's working.
Thanks to all :)