github.com/chelnak/go-gh@v0.0.2/README.md (about) 1 # go-gh beta 2 3 **This project is in beta!** Feedback is welcome. 4 5 A Go module for CLI Go applications and [gh extensions][extensions] that want a convenient way to interact with [gh][], and the GitHub API using [gh][] environment configuration. 6 7 `go-gh` supports multiple ways of getting access to `gh` functionality: 8 9 * Helpers that automatically read a `gh` config to authenticate themselves 10 * `gh.Exec` shells out to a `gh` install on your machine 11 12 If you'd like to use `go-gh` on systems without `gh` installed and configured, you can provide custom authentication details to the `go-gh` API helpers. 13 14 15 ## Installation 16 ```bash 17 go get github.com/cli/go-gh 18 ``` 19 20 ## Usage 21 ```golang 22 package main 23 import ( 24 "fmt" 25 "github.com/cli/go-gh" 26 ) 27 28 func main() { 29 // These examples assume `gh` is installed and has been authenticated 30 31 // Execute `gh issue list -R cli/cli`, and print the output. 32 args := []string{"issue", "list", "-R", "cli/cli"} 33 stdOut, _, err := gh.Exec(args...) 34 if err != nil { 35 fmt.Println(err) 36 return 37 } 38 fmt.Println(stdOut.String()) 39 40 // Use an API helper to grab repository tags 41 client, err := gh.RESTClient(nil) 42 if err != nil { 43 fmt.Println(err) 44 return 45 } 46 response := []struct{ Name string }{} 47 err = client.Get("repos/cli/cli/tags", &response) 48 if err != nil { 49 fmt.Println(err) 50 return 51 } 52 fmt.Println(response) 53 } 54 ``` 55 56 See [examples][examples] for more use cases. 57 58 ## Reference Documentation 59 60 Full reference docs can be found on [pkg.go.dev](https://pkg.go.dev/github.com/cli/go-gh). 61 62 ## Contributing 63 64 If anything feels off, or if you feel that some functionality is missing, please check out the [contributing page][contributing]. There you will find instructions for sharing your feedback, and submitting pull requests to the project. 65 66 [extensions]: https://github.com/topics/gh-extension 67 [gh]: https://github.com/cli/cli 68 [examples]: ./example_gh_test.go 69 [contributing]: ./.github/CONTRIBUTING.md