使用Go应用程序将生成的文件推送到github
问题描述:
I'm working in an application that generates files, and I would like to push those files to a github repo. Is that possible to do from within the app?
我正在生成文件的应用程序中工作,我想将这些文件推送到github存储库中。 可以在应用程序内完成吗? p> div>
答
Try the package go-git. It allows you to perform git clone/commit/push operations. It can clone a tree in-memory too without requiring disk access.
From the the commit example is a sample add/commit:
_, err = w.Add("example-git-file")
CheckIfError(err)
commit, err := w.Commit("example go-git commit", &git.CommitOptions{
Author: &object.Signature{
Name: "John Doe",
Email: "john@doe.org",
When: time.Now(),
},
})