We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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 version
$ go 1.16.11
我是这样做的改动
HttpEmbed
package httpEmbed import ( "embed" "io/fs" "path" "path/filepath" ) type Fs struct { *embed.FS // 静态资源 Path string // 设置embed文件到静态资源的相对路径,也就是embed注释里的路径 } func (f Fs) Open(name string) (fs.File, error) { // 拼接相对路径 fullName := filepath.Join(f.Path, filepath.FromSlash(path.Clean("/"+name))) // 修改http路径中的\为/ fullName = filepath.ToSlash(fullName) //fmt.Println(fullName) fs, err := f.FS.Open(fullName) return fs, err }
The text was updated successfully, but these errors were encountered:
Sorry, we can't help with non-English issues on the tracker. See: https://github.com/golang/go/wiki/NonEnglish and for questions: https://github.com/golang/go/wiki/Questions.
Sorry, something went wrong.
The io.FS package always uses forward slashes. See https://pkg.go.dev/io/fs#ValidPath.
io.FS
No branches or pull requests
What version of Go are you using (
go version
)?我是这样做的改动
HttpEmbed
The text was updated successfully, but these errors were encountered: