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))
}