Closed razonyang closed 4 years ago
I think it makes sense we only support absolute path, I can't think of a use case where we don't use it. Hence one option here is to either prepend slash when missing or just update the documentation to specify this. Any thoughts on this @rakyll?
On Wed, 11 Mar 2020, 00:52 Razon Yang, notifications@github.com wrote:
I modified the example https://github.com/rakyll/statik/blob/master/example/main.go, relative path seems not working.
Code snippet:
func main() { statikFS, err := fs.New() ... for , name := range []string{"hello.txt", "/hello.txt"} { , err := statikFS.Open(name) if err != nil { log.Printf("file %s: %s", name, err) } else { log.Printf("file %s exists", name) } } ... }
$ go run main.go 2020/03/11 07:50:11 file hello.txt: file does not exist 2020/03/11 07:50:11 file /hello.txt exists
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rakyll/statik/issues/109?email_source=notifications&email_token=AAXOYAU2RM2TYC3PB35A3CTRG3HCNA5CNFSM4LFKGZ72YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IUBWPEA, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXOYAS7AAW5WVDZ6YI63PLRG3HCNANCNFSM4LFKGZ7Q .
@jcchavezs Thx, I solved it by adding a forward slash.
But, IMO, a file system(http.FileSystem
) should be able to open relative path files, such as http.Dir
and packr.Box
.
I modified the example, relative path seems not working.
Code snippet: