-
Notifications
You must be signed in to change notification settings - Fork 224
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
Multiple static file packages #56
Comments
@titpetric here is a fork'd version with the fix.. https://github.com/goware/statik as well as a new -a flag to pass pkg-level variable name to reference the asset. And fs.New() which accept the zipdata string |
This request would change this project from a very minimalist solution to a more general one, but less lightweight. If you need something less minimalist, just fork the project to build something else. |
Well, in fact, you can already do that with the existing code. The trick is to import the statik packages in separate packages and to call Example: package pkg1
import (
"github.com/rakyll/statik/fs"
_ "pkg1/statik"
)
var FS = fs.New() package pkg2
import (
"github.com/rakyll/statik/fs"
_ "pkg2/statik"
)
var FS = fs.New() You can now use both Note: this is garanteed to work because the Go language specification garantees that "Package initialization—variable initialization and the invocation of init functions—happens in a single goroutine, sequentially, one package at a time." |
@pkieltyka thanks, i like that you moved away from Closing this issue as I don't think my PR is a good way forward. Moving away from init() will be a breaking change either way, and it's not up to me. |
@pkieltyka p.s. would be nice if you'd generate |
Hi! I just hit the same problem. I have two directories in two package and I was very surprise to discover that they are on the same Filesystem. I love the minimalism of statik but this was unexpected. |
I'd like to produce two (or more) different statik fs's in different import paths. Due to relying on
init()
and no public API from the package, it's impossible to use both filesystems at the same time; concurrent access is also impossible asfs.Register
is package-scoped.I'd propose modifying the API:
fs.New
would takezipDatas ...string
and fallback on whatever was put infs.Register
(backwards compatible),The generated filesystem package could add
Data() string
for this purpose in addition to keeping init() behaviour.The text was updated successfully, but these errors were encountered: