Closed mntlty closed 1 year ago
A concrete implementation is in https://github.com/cli/go-gh/commit/114787b4c315071b4b7c8f2cb95256da09e44f3b in case this makes sense to others
Thanks for bringing this up. Will the examples still get rendered of on the main page of generated docs? If so, I'm in favor of this 👍
@mislav I ran godoc -http=:6060
on the example branch, and it renders the examples while adding the gh
package. Comparing local output for http://localhost:6060/pkg/github.com/cli/go-gh/#example_RESTClient_advanced
From trunk:
opts := api.ClientOptions{
Host: "github.com",
AuthToken: "xxxxxxxxxx", // Replace with valid auth token.
Headers: map[string]string{"Time-Zone": "America/Los_Angeles"},
Log: os.Stdout,
}
client, err := RESTClient(&opts)
if err != nil {
log.Fatal(err)
}
response := []struct{ Name string }{}
err = client.Get("repos/cli/cli/tags", &response)
if err != nil {
log.Fatal(err)
}
fmt.Println(response)
From the example branch:
opts := api.ClientOptions{
Host: "github.com",
AuthToken: "xxxxxxxxxx", // Replace with valid auth token.
Headers: map[string]string{"Time-Zone": "America/Los_Angeles"},
Log: os.Stdout,
}
client, err := gh.RESTClient(&opts)
if err != nil {
log.Fatal(err)
}
response := []struct{ Name string }{}
err = client.Get("repos/cli/cli/tags", &response)
if err != nil {
log.Fatal(err)
}
fmt.Println(response)
is there something else I should check for?
Nice, thanks for checking! Please send a PR for this 🙇
done!
Being in the same package, the example test file can refer to functions such as
RESTClient
andExec
as local, as opposed togh.RESTClient
andgh.Exec
. This presents some challenges:I would like to suggest changing the package of the example file and updating the functions in it.