shuLhan / go-bindata

A small utility which generates Go code from any file. Useful for embedding binary data in a Go program.
Creative Commons Zero v1.0 Universal
189 stars 26 forks source link

escaping the \ character in the file path #16

Open SQLServerIO opened 7 years ago

SQLServerIO commented 7 years ago

On Windows the file paths are normally \ and not / and when you include a directory it generates code that will not build.

My example: go-bindata -ignore=\*.bak -o assets.go scripts\

in my assets.go file I end up with scripts\file name and that throws an error due to the unescaped \ in release.go the offending line is info := bindataFileInfo{name: %q, size: %d, mode: os.FileMode(%d), modTime: time.Unix(%d, 0)} I'm assuming that %q needs to be sanitized.

shuLhan commented 7 years ago

@SQLServerIO ,

Since I don't have Windows machine to test the output, I try to blind fix this on branch dev-shulhan. Can you give it a try?

RamonSmit commented 7 years ago

Forward slash is working in Windows as well. Must not be a problem since Windows Vista

joerocklin commented 6 years ago

@shuLhan You can grab a windows VM from Microsoft at https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/. They're intended for browser testing, but I've not seen any restrictions on installing other software.

Windows has supported both slashes as path separators for a very long time (back in the early DOS days). The dev branch worked for me with the exception that it required a directory component for the output file: https://github.com/shuLhan/go-bindata/blob/4ec947ecc450dcdbe00746e8477d15216fb37732/config.go#L226-L231

It looks like this might be part of a new mechanism for handling the output, but it breaks the existing scenario where the output is defined to be a single file.

shuLhan commented 6 years ago

@SQLServerIO,

I have installed Windows in virtual machine just to test and try to fix this bug but I can't reproduce it. Can you give more information about error message, list of files in your scripts directory, version of Go, version go-bindata that you were using? Thank you.

shuLhan commented 6 years ago

@SQLServerIO Can you please try again with latest version. Thank you.