UnnoTed / fileb0x

a better customizable tool to embed files in go; also update embedded files remotely without restarting the server
MIT License
634 stars 53 forks source link

Fix execution on some environments: os.Args[0] is not the current directory #7

Closed andreynering closed 7 years ago

andreynering commented 7 years ago

Go can understand relative paths. No need to convert to absolute.

EDIT: just to explain.

A command like this:

fileb0x mybox.yaml

Woks on cmd on Windows, but not on Git bash, because the command will to converted to:

C:\<...>\GOPATH\bin\fileb0x.exe mybox.yaml

So it returns an error like this:

2017/03/04 15:29:01 Error: I Can't find the config file at [C:\<...>GOPATH\bin\fileb0x_templates.yaml]

This is because os.Args[0] constains the executable path, not the working directory.

An alternative would be using os.Getwd(), but Go does that automatically.

UnnoTed commented 7 years ago

Sorry, i forgot to merge this, thanks!