You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Modules from this library will obey GitHub CLI conventions by default:
repository.Current() respects the value of the GH_REPO environment variable and reads from git remote configuration as fallback.
GitHub API requests will be authenticated using the same mechanism as gh, i.e. using the values of GH_TOKEN and GH_HOST environment variables and falling back to the user's stored OAuth token.
Terminal capabilities are determined by taking environment variables GH_FORCE_TTY, NO_COLOR, CLICOLOR, etc. into account.
Generating table or Go template output uses the same engine as gh.
The browser module activates the user's preferred web browser.
package main
import (
"fmt""log""github.com/cli/go-gh/v2""github.com/cli/go-gh/v2/pkg/api"
)
funcmain() {
// These examples assume `gh` is installed and has been authenticated.// Shell out to a gh command and read its output.issueList, _, err:=gh.Exec("issue", "list", "--repo", "cli/cli", "--limit", "5")
iferr!=nil {
log.Fatal(err)
}
fmt.Println(issueList.String())
// Use an API client to retrieve repository tags.client, err:=api.DefaultRESTClient()
iferr!=nil {
log.Fatal(err)
}
response:= []struct{
Namestring
}{}
err=client.Get("repos/cli/cli/tags", &response)
iferr!=nil {
log.Fatal(err)
}
fmt.Println(response)
}
If anything feels off, or if you feel that some functionality is missing, please check out our contributing docs. There you will find instructions for sharing your feedback and for submitting pull requests to the project. Thank you!
About
A Go module for interacting with gh and the GitHub API from the command line.