GO API to upload a directory in the github

289 views
Skip to first unread message

PK

unread,
Sep 28, 2022, 12:46:29 AM9/28/22
to golang-nuts
HI Everyone,
I want to write an go script, to upload a folder in the github. Can anyone please let How I can do this. Is there any resources available for this.
Please help me in this.

Eg: I have a temp folder in my local machine, I want to upload it to one of the github repo.

Amnon

unread,
Sep 28, 2022, 2:29:24 AM9/28/22
to golang-nuts

Reto

unread,
Sep 28, 2022, 2:21:36 PM9/28/22
to PK, golang-nuts
On Tue, Sep 27, 2022 at 09:46:04PM -0700, PK wrote:
> I want to write an go script, to upload a folder in the github. Can anyone
> please let How I can do this.

Depending on what you mean by "upload folder" you can either use git,
assuming you meant source code / version tracked stuff or you can
interact with the GH API either via rest or grahpql.

There's a bunch of info available, say

* https://docs.github.com/en/developers/overview/about-githubs-apis
* https://github.com/shurcooL/githubv4

Go from there.


Cheers,
Reto

PK

unread,
Oct 4, 2022, 1:29:53 AM10/4/22
to golang-nuts
yes, I tried with the help of  https://github.com/go-git/go-git
and there is a basics example (git clone) is given, but when I compile that, it shows the following compilation errors:

# github.com/kevinburke/ssh_config
/root/go/src/github.com/kevinburke/ssh_config/config.go:318:12: undefined: os.ReadFile
/root/go/src/github.com/kevinburke/ssh_config/config.go:333:12: undefined: io.ReadAll
# golang.org/x/sys/unix
/root/go/src/golang.org/x/sys/unix/syscall.go:84:16: undefined: unsafe.Slice
/root/go/src/golang.org/x/sys/unix/syscall_linux.go:2255:9: undefined: unsafe.Slice
/root/go/src/golang.org/x/sys/unix/syscall_unix.go:118:7: undefined: unsafe.Slice
/root/go/src/golang.org/x/sys/unix/sysvshm_unix.go:33:7: undefined: unsafe.Slice
# golang.org/x/crypto/ssh
/root/go/src/golang.org/x/crypto/ssh/cipher.go:499:13: undefined: io.Discard
/root/go/src/golang.org/x/crypto/ssh/session.go:508:14: undefined: io.Discard
/root/go/src/golang.org/x/crypto/ssh/session.go:521:14: undefined: io.Discard

Brian Candler

unread,
Oct 4, 2022, 5:47:49 AM10/4/22
to golang-nuts
> undefined: io.Discard

What version of Go are you running on your system?

io.Discard was introduced in go 1.16.  unsafe.Slice was added in go 1.17.  The most recent version is 1.19, and I'd recommend you use that.
Reply all
Reply to author
Forward
0 new messages