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

embed.FS broken on Windows #12

Closed
shemanaev opened this issue Aug 27, 2022 · 3 comments · Fixed by #14
Closed

embed.FS broken on Windows #12

shemanaev opened this issue Aug 27, 2022 · 3 comments · Fixed by #14
Labels
bug Something isn't working

Comments

@shemanaev
Copy link

Summary

Go uses forward slashes for embed.FS even on Windows builds and loader can't find files with names made with filepath.Join.

Relevant issues: golang/go#45230, golang/go#44305

Steps to reproduce

Move locale/es.po to locale/es/helloworld.po in example.

Expected behavior

Load locales.

Observed behavior (that appears unintentional)

It doesn't load 😄.

@vorlif
Copy link
Owner

vorlif commented Aug 28, 2022

Hi @shemanaev,

Thanks for bringing up this point and for your research!

I'll have to have a look at how best to solve the problem while remaining compatible with the normal and embedded filesystem.

As a temporary fix, you could use a custom revolver with path.Join.

fsLoader, errFS := spreak.NewFilesystemLoader(
	spreak.WithResolver(&yourResolver{}),
	spreak.WithFs(yourFs),
)

@vorlif vorlif added the bug Something isn't working label Aug 28, 2022
vorlif added a commit that referenced this issue Sep 4, 2022
@vorlif vorlif closed this as completed in #14 Sep 4, 2022
vorlif added a commit that referenced this issue Sep 4, 2022
@vorlif
Copy link
Owner

vorlif commented Sep 4, 2022

That took longer than it should have. Unfortunately, there is no way to determine if it is an embedded filesystem. But according to the fs documentation, slashes should be used as path separators for fs.FS implementations anyway.

However, I have now created a new release, with which it should also work under Windows. Thanks for your report.

@shemanaev
Copy link
Author

Everything works perfect now. Thank you! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants