nishanths / license

Command line license text generator.
MIT License
663 stars 82 forks source link

Use Go 1.16 embed rather than go-bindata #29

Closed ghost closed 3 years ago

ghost commented 3 years ago

Concept

As of Go 1.16, the embed package allows embedding arbitrary files into variables in code. I think that using this built in rather than depending on an external tool like go-bindata is nicer and the code itself is much cleaner and easier to read.

Rationale

The way that embed works is by adding a directive comment with the target file's path above a variable declaration, such as a string or byte slice, and the compiler sets that variable to the contents of that file at build time. This is basically what we do now when we regenerate templates.go with go-bindata, however, embed has two main advantages over go-bindata:

  1. embed is a part of the build. This makes it easier for new contributors as using go-bindata wasn't really obvious to me when I was making my first contribution here.
  2. Adding or updating licenses becomes as simple as editing the .txt file in question, with no code changes needed. Where as we currently need to regenerate templates.go.

Design

I've been meaning to add this since I read about embed in the release notes so I'll probably make a prototype on my fork at some point. I just wanted to feel out if this would be wanted / if there are any design considerations to make.

ghost commented 3 years ago

Note: see yuri-norwood#2 for development notes.

nishanths commented 3 years ago

I just wanted to feel out if this would be wanted / if there are any design considerations to make.

I'm sorry I didn't read this part of the issue description earlier (and so missed to respond). Thank you for making the pull request.