Skip to content
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

go 1.16 compatibility #275

Closed
xakep666 opened this issue Nov 22, 2020 · 2 comments · Fixed by #291
Closed

go 1.16 compatibility #275

xakep666 opened this issue Nov 22, 2020 · 2 comments · Fixed by #291

Comments

@xakep666
Copy link
Contributor

xakep666 commented Nov 22, 2020

It seems that future releases of go will bring us new io/fs package with some interfaces for file system (https://tip.golang.org/pkg/io/fs).
Is it possible to make afero compatible with io/fs?

@VoyTechnology
Copy link

Based on a quick investigation, it looks like the only place where a change might be needed is

type File interface {
    Stat(name string) (os.FileInfo, error) // return fs.FileInfo instead
}

However, also looking at os package it looks like it would be still working fine without changing it.

type FileInfo = fs.FileInfo

@cugu
Copy link
Contributor

cugu commented Jan 24, 2021

afero uses afero.File while fs uses fs.File, which are quite different so this would require some refactoring.

A simple example:

info, _ := fs.Stat(afero.NewMemMapFs(), ".")
fmt.Println(info)

results in

./main.go:12:38: cannot use afero.NewMemMapFs() (type afero.Fs) as type fs.FS in argument to fs.Stat:
	afero.Fs does not implement fs.FS (wrong type for Open method)
		have Open(string) (afero.File, error)
		want Open(string) (fs.File, error)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants