duannei0044
2016-01-19 01:45
浏览 137
已采纳

用os.exec(“ git”,“ clone”)克隆仓库

Running the code below, I expected the github hosted project username/mysuperrepo to be cloned (once I visit the clone path) into the repo where this go project is running, but it doesn't work. After stopping the application, there's no directory for mysuperrepo no any of the files that I would expect from running git clone https://github.com/username/mysuperrepo.git from the command line

Question: Why wouldn't the code below produce a clone of the repo in the directory where the go program is running?

func clone(w http.ResponseWriter, r *http.Request){
  var repo = "https://github.com/username/mysuperrepo.git"
  exec.Command("git", "clone", repo)
  w.Write([]byte(repo))
}
func main(){
  http.HandleFunc("/clone/", clone)
  log.Fatal(http.ListenAndServe(":8080", nil))
}

图片转代码服务由CSDN问答提供 功能建议

运行以下代码,我希望克隆github托管项目 username / mysuperrepo (一旦我访问 clone 路径)进入运行此go项目的存储库,但是它不起作用。 停止应用程序后,没有目录 mysuperrepo ,没有我希望运行 git clone https://github.com/username/mysuperrepo.git 的任何文件 来自命令行

问题:为什么下面的代码在go程序运行所在的目录中无法生成仓库的克隆?

  func clone(w http.ResponseWriter,r * http.Request){
 var repo =“ https://github.com/username/mysuperrepo.git” \  n exec.Command(“ git”,“ clone”,repo)
 w.Write([] byte(repo))
} 
func main(){
 http.HandleFunc(“ / clone /”,clone  )
 log.Fatal(http.ListenAndServe(“:8080”,nil))
} 
   
 
  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题