golang git pulling a repo

Viewed 12420

I'm very new to golang Im trying to do a git pull from go program. I have looked in to native libraries and found https://github.com/src-d/go-git/.

I has features to of cloning ect. but not pulling. Looking at the source it seems there is a function for pulling as well

func (r *Repository) Pull(o *PullOptions) 

However compiler warns that its undefined. Can anyone point me how can I do this or to an alternative library which supports both clone and pull ?

2 Answers

gopkg.in/src-d/go-git.v4 is no longer maintained recommended to use github.com/go-git/go-git instead. Refer - https://pkg.go.dev/github.com/go-git/go-git

Sample code

import "github.com/go-git/go-git/v5"

_, err := git.PlainClone("/tmp/foo", false, &git.CloneOptions{
    URL:      "https://github.com/go-git/go-git",
    Progress: os.Stdout,
})
Related