-
-
Save zchee/444c8c20aa7756468d8e to your computer and use it in GitHub Desktop.
Revisions
-
xorpaul created this gist
Jul 27, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ package main import ( git "github.com/libgit2/git2go" "log" ) func credentialsCallback(url string, username string, allowedTypes git.CredType) (git.ErrorCode, *git.Cred) { ret, cred := git.NewCredSshKey("git", "/home/vagrant/.ssh/id_rsa.pub", "/home/vagrant/.ssh/id_rsa", "") return git.ErrorCode(ret), &cred } // Made this one just return 0 during troubleshooting... func certificateCheckCallback(cert *git.Certificate, valid bool, hostname string) git.ErrorCode { return 0 } func main() { cloneOptions := &git.CloneOptions{} // use FetchOptions instead of directly RemoteCallbacks // https://github.com/libgit2/git2go/commit/36e0a256fe79f87447bb730fda53e5cbc90eb47c cloneOptions.FetchOptions = &git.FetchOptions{ RemoteCallbacks: git.RemoteCallbacks{ CredentialsCallback: credentialsCallback, CertificateCheckCallback: certificateCheckCallback, }, } repo, err := git.Clone("[email protected]:username/private-repository.git", "private-repo", cloneOptions) if err != nil { log.Panic(err) } log.Print(repo) }