-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat: embed, io/fs support #471
Comments
Thanks for sharing! There's already support for a httpfs source ( I believe, if an We'll need to add a build constraint for |
* Add io/fs#FS Driver #471 * Refactor iofs.Iofs to be independent of httpfs * Rename Iofs to IoFS, accepts fs.FS and use fs.DirEntry.Info() to undo the changes in ErrDuplicateMigration * fix documents and migration directory for testing * Fix iofs.Driver so that it can be used by embedding it like httpfs.PartialDriver * iofs.Driver closes the file system if possible * Rename receiver * Refactor file driver to use iofs.Driver * iofs build constraint is not needed so remove it * Properly return an error in a corner case * Increase golangci-lint timeout * Fix example code * Revert "Increase golangci-lint timeout" This reverts commit 2cd12a6. * unexport driver, add iofs.PartialDriver, remove type alias from file driver * do not panic in Open, return error
This reverts commit fedbe42.
We will not be able to include this feature until Go 1.15 is no longer supported. #480 |
Re-opening and will revert the revert when Go 1.15 is no longer supported by |
Update: I was to late, this was already implemented with golang-migrate#471. Closes golang-migrate#507
Possible workaround until Go 1.15 is no longer supported:
import "github.com/golang-migrate/migrate/v4/source/httpfs"
//go:embed migrations
var migrations embed.FS
source, err := httpfs.New(http.FS(migrations), "migrations")
// migrate.NewInstance("httpfs", source, ...) |
We should use build tags to support 1.16 features and keep the support for 1.15 at least until 1.17 is released Take an example from here: |
The PR that added support for |
Thank you so much! |
Go 1.16.2 and Go 1.15.10 (which were just released) include a fix for golang/go#44557, meaning that io/fs and embed can be depended on and not break downstream users when they |
any chance to get embed support in golang-migrate ? |
Let's wait a bit more time (about a month or two) for the newer versions of Go to be adopted. Your other option is to fork this library and merge the PR into your fork. |
Did we wait enough time? :) |
https://groups.google.com/g/golang-announce/c/cu9SP4eSXMc?pli=1
1.15.12 is already here! P.S. just to support my previous comment :) |
i think that we wait enough. embed stuff not changed and not contains any bugs |
What about using build tag for this, that restricts the compilation to Go 1.16 and onwards? |
Fixed by #560 |
Is your feature request related to a problem? Please describe.
The next Go 1.16 will add official file system interface and file embedding.
golang/go#41190
/~https://github.com/golang/go/tree/master/src/io/fs
golang/go#41191
/~https://github.com/golang/go/tree/master/src/embed
It would be great if golang-migrate supports these as source.Driver.
It replaces statik, go-bindata, and pkger.
Of course, this does not mean that they cannot be used.
Describe the solution you'd like
Describe alternatives you've considered
Additional context
We will also need to use the build tag properly.
The text was updated successfully, but these errors were encountered: