Closed pkaramol closed 4 years ago
I am using go-git to checkout a repository, and then open a file as in:
go-git
fs := memfs.New() repo, err := git.Clone(memory.NewStorage(), fs, &git.CloneOptions{ URL: "git@github.com:pkaramol/somerepo.git", ReferenceName: "refs/heads/somebranch", Depth: 1, Auth: auth, }) if err != nil { log.Fatalf(err.Error()) } file, err := fs.Open("somedir/somefile.yaml") if err != nil { log.Fatalf(err.Error()) } fmt.Println(repo) fmt.Printf("%T\n", file)
The last print informs me that what I get by opening an in-memory file is *chroot.file
*chroot.file
My question is whether (and if yes, how) can I manipulate this type so as to achieve the same results, had it been a os.File.
os.File
e.g. given that in my specific example I am opening a .yaml file, can I use the normal marshalling process etc?
.yaml
*chroot.file (which I confuse with billy.File) implements the io.Reader interface so the rest is easy to figure out. Sorry about this.
billy.File
io.Reader
I am using
go-git
to checkout a repository, and then open a file as in:The last print informs me that what I get by opening an in-memory file is
*chroot.file
My question is whether (and if yes, how) can I manipulate this type so as to achieve the same results, had it been a
os.File
.e.g. given that in my specific example I am opening a
.yaml
file, can I use the normal marshalling process etc?