I want to be able to do run-time git
manipulations with go
.
I recently discovered the go-git
package which comes in very handy to this end.
I was also able to perform pull
operations, more or less as follows:
import {
git "gopkg.in/src-d/go-git.v4"
}
repo, err := git.Clone(memory.NewStorage(), nil, &git.CloneOptions{
URL: "https://github.com/pkaramol/myrepo",
})
err := repo.Pull(&git.PullOptions{
RemoteName: "origin"
})
My question is, assuming I am using in-memory checkout of the repo as above), how will I be able to read in (my go
program) a file from the repository? i.e. assuming the file
https://github.com/pkaramol/myrepo/someConfig.yaml
Would it be preferable (in case I need just this particular file) to perform a git clone (still in mem) of only the particular file?