go-git / go-billy

The missing interface filesystem abstraction for Go
https://pkg.go.dev/github.com/go-git/go-billy/v5
Apache License 2.0
324 stars 43 forks source link

Example code on How to get an instance of an object/struct that implements billy.Filesystem? #21

Closed micwin closed 2 years ago

micwin commented 2 years ago

Hello folks,

I know it sounds like a rookie question and that surely is the case ...

not being such a golang guru, and trying to use https://github.com/go-git, I happened to come along the billy filesystem abstraction.

Well, I like abstraction and billy looks very fine so far, so I tried to get some instances but not achieving somehow. Then tried to get some example code and the only thing I find is the projects' homepage; but to no avail, because there is no source code where I could find out how to get an instance of type billy.Filesystem, only what to do with it if one has gotten one from somewhere. What I tried to code was something like:

myFileSystem := Filesystem (pathToFileSystem) and myFileSystem := billy.Filesystem (pathToFileSystem)

and following the projects' statement on the homepage, stating that

each Filesystem implementation gives you a New method

i tried

myFileSystem := Filesystem.New (pathToFileSystem) and myFileSystem := Basic.New (pathToFileSystem) and myFileSystem := Dir.New (pathToFileSystem)

and even, prefixing the above with billy, like so:

myFileSystem := billy.Filesystem.New (pathToFileSystem)

I also tried a little bit around with ioutil ... but whatever I do, I dont find a constructor that takes a string path and gives back an instance of billy.Filesystem.

As mentioned, yes it might be a golang rookies' question and I might be as dumb as hell, but... please relieve me,...

Best Regards,

Michael

Edit: wayyy too much typos

micwin commented 2 years ago

Literally two seconds later I found the solution. osfs.New scrn