-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go: handle program or library assets #3035
Comments
Sure, but I don't think we'll attack this for Go 1. Labels changed: added priority-later, removed priority-triage. Owner changed to builder@golang.org. Status changed to Accepted. |
I wrote a patch that handles assets by automatically generating Go files. https://groups.google.com/forum/?fromgroups#!topic/golang-nuts/UOIUyn7uFsY (my post with the diffs is in the moderation queue right now) |
a .syso-based solution: https://groups.google.com/forum/#!msg/golang-nuts/UOIUyn7uFsY/Uescy-cI7hQJ IMHO, if cmd/go need to do this, it should do this by generating a .syso file. |
This would be really useful. I have a JSON file that contains a database of terminals -- this file could be compiled into the Go program, but its really extension info, and adding it bloats the text of the program by some 2MB at run time. Since only about 0.1% of users need it, its better to leave it in JSON. Ideally, go install could be made to install these resource files (perhaps by having a special file list what they are) in a standard directory based on the location of the binary, and then a little API glue to support picking the file up by the package name & binary location? Absent this, I'm inclined to use $HOME/. and hope for the best. |
Just wanted to bump on this old issue. For general stuff, the plugin model released in 1.8 should be sufficient for this. You can expose assets as a function or a variable. In the golang-nuts thread above, folks mostly wanted to embed static assets in their binaries, which is usually done with go generate and a tool to generate the files, like statik. @rsc @bradfitz - Are we looking to do anything more on this ? |
Plugins are not the answer here. (Plugins are hard to use and not very portable) This bug is about adding some conventions to the $GOPATH file layout, respected by the cmd/go tool, to automatically take files off the filesystem and place their contents (and perhaps their metadata like modtime) into the output, perhaps as a compressed ELF section or some equally efficient depending on the platform. As a strawman, you could imagine a |
Makes sense. Thanks ! |
Rust has an include_str! macro which works like this:
If the file I haven't look at the implementation, but something similar in Go would be useful for example for templates and SQL queries. |
Closing as a duplicate of #35950 which now has an active discussion. |
by untheoretic:
The text was updated successfully, but these errors were encountered: