简体   繁体   中英

Pushing a generated file to github from with a Go application

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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