asticode / go-astilectron-bundler

Bundle your Astilectron app with ease
MIT License
129 stars 68 forks source link

Bundling while having an external configuration file #36

Closed MeuhMeuh closed 5 years ago

MeuhMeuh commented 5 years ago

Hello,

First of all, thanks for your work on your tools suite.

I'm struggling with the bundler as I'm trying to bundle my app that is (on the Go part) reading an external JSON file to get some configuration.

The bundler successfully bundles my app, but I unfortunately can't run it - it's closing straight after I open it. When running it via CLI, I indeed have an error related to my missing configuration (conf.json file that should be located in a config/ folder at the root of my app) :

panic: Could not read the configuration file : Config File "conf" Not Found in "[/Users/meuhmeuh/Projects/go/src/github.com/xxx/output/darwin-amd64/xxx.app/Contents/MacOS/config]"

goroutine 1 [running]:
main.main()
    /Users/meuhmeuh/Projects/go/src/github.com/xxx/main.go:18 +0x206

Do you know how I could embed this configuration file within the app in some way? The only solution that I could see from my perspective would be to embed the json configuration file on the electron app's side and to send it to the Go backend, but I'm not sure if it's that sexy.

Thanks !

MeuhMeuh commented 5 years ago

Using packr seems to do the trick.

asticode commented 5 years ago

@MeuhMeuh what you could have done:

That way you can access your config file with resources/config.file for instance.

Let me know if you have any questions.