简体   繁体   English

Golang克隆私人github存储库

[英]Golang clone private github repository

I am writing a go-lang app and I need to: 我正在编写Go-lang应用程序,我需要:

  1. Go to the sibling directory tried with: 转到尝试使用的同级目录:

    exec.Command("/bin/sh", "-c", "cd ..").Output()

  2. And clone/update GitHub private repository: git clone ....GitHub repository 并克隆/更新GitHub私有存储库:git clone .... GitHub存储库

I cannot accomplish neither of those tasks. 我无法完成这些任务。 I tried GitHub/libgit2/git2go but on Ubuntu 16.04 libgit2 cannot understand https. 我尝试了GitHub / libgit2 / git2go,但是在Ubuntu 16.04上, libgit2无法理解https。

Thank you for any help. 感谢您的任何帮助。

Credits comes to @JimB :-) 积分来自@JimB :-)

 func update_ghub(wg *sync.WaitGroup) {
    var (
        cmdOut []byte
        err    error
    )
    err = os.Chdir("/home/svitlana/go/src/realsiter/realster")
    if err != nil {
        log.Fatalln(err)
    }

    cmdName := "git"
    cmdArgs := []string{"pull"}

    if cmdOut, err = exec.Command(cmdName, cmdArgs...).Output(); err != nil {
        fmt.Fprintln(os.Stderr, "There was an error running git rev-parse command: ", err)
        os.Exit(1)
    }
    sha := string(cmdOut)
    fmt.Println("Response:", sha)
    wg.Done()
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM