gitfs icon indicating copy to clipboard operation
gitfs copied to clipboard

error when using go run github.com/posener/gitfs/cmd/gitfs ./...

Open segator opened this issue 5 years ago • 3 comments
trafficstars

this is the error

Failed encoding filesystem "github.com/segator/transcoderd": opening file .git\COMMIT_EDITMSG: http: invalid character in file path

in my main.go i have this

err := gitfs.New(ctx,
		"github.com/segator/transcoderd",)

the working dir where main.go exists is a git repo poiting to github.com/segator/transcoderd

any idea?

segator avatar Jun 17 '20 13:06 segator

Hey, are you using a windows machine by any chance?

posener avatar Jun 17 '20 15:06 posener

Yes I am

segator avatar Jun 17 '20 20:06 segator

I see. The Windows' forward slash looks to cause the error. I guess here: https://github.com/posener/gitfs/blob/23d43300579d7c7b147ca7cc93adad6c94ec8291/internal/binfs/binfs.go#L142

I think that the error is here: https://github.com/posener/gitfs/blob/23d43300579d7c7b147ca7cc93adad6c94ec8291/internal/localfs/localfs.go#L28

When reading from a Windows filesystem, the path parts are joined with a forward slash, but since we are building an "http" filesystem, we should join them with backward slash.

posener avatar Jun 18 '20 05:06 posener