【发布时间】:2023-01-14 07:34:25
【问题描述】:
我想使用 https://github.com/google/go-github 来评论问题,但是这个测试代码:
package main
import (
"golang.org/x/oauth2"
"github.com/google/go-github/v49/github"
)
func main() {
ctx := context.Background()
ts := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: "token_here"},
)
tc := oauth2.NewClient(ctx, ts)
client := github.NewClient(tc)
// list all repositories for the authenticated user
repos, _, err := client.Repositories.List(ctx, "", nil)
}
但我刚开始
# command-line-arguments
./main.go:9:9: undefined: context
./main.go:18:2: repos declared but not used
./main.go:18:12: err declared but not used
背部... 那么 - 我必须做些什么才能使它正常工作以及如何(通过我的令牌)向 github 上的问题发送评论?
多谢!
我测试了来自 https://github.com/google/go-github 的示例代码,但我失败了,因为我对编程和 Go 太陌生了。
【问题讨论】:
标签: go github-api go-github