asticode / go-astilectron-bundler

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

Add Bind Data Package Path Property #73

Closed iangallOlive closed 4 years ago

iangallOlive commented 4 years ago

This originated because I had to set the bind data's output_path to a subdirectory in my project.

Specifically, I'm setting output_path to "bind", so that all bind_*.go files go into ./bind/, and I reference them by importing github.com/my/module/bind. This works well, except the ldflags that are set by this bundler (AppName, BuiltAt, etc.) no longer work. This is because the go build flags that end up being set are like -X "bind.AppName=.... The problem with this is that go build doesn't target the bind package in the way you'd expect (I'd expect how everything's currently set up to just work). Apparently, you need to use the full path (I'm not sure of the right name of this) to it, from the root of your project/module. But anyway, I needed the option to set the target package used in the ldflags different from the actual package used for the bindata config. So in the end, this is what the relevant part of my bundler.json would look like:

{
  "bind": {
    "output_path": "bind",
    "package": "bind",
    "package_path": "github.com/my/module/bind"
  }
}

This PR should leave everything working the same as it always has, but adds the ability to set the package used in ldflags if you want.

Also, added more info for this bind data stuff to the README, and did some random cleanup.

iangallOlive commented 4 years ago

@asticode Hopefully resolved everything you requested! Let me know if you want anything else changed, I'm happy to do whatever!

asticode commented 4 years ago

FYI I've created a v0.6.0 tag

iangallOlive commented 4 years ago

@asticode Thank you so much for the review/merge/tag!