MCPcopy Index your code
hub / github.com/google/go-github / main

Function main

test/fields/fields.go:38–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36)
37
38func main() {
39 flag.Parse()
40
41 token := os.Getenv("GITHUB_AUTH_TOKEN")
42 if token == "" {
43 fmt.Print("!!! No OAuth token. Some tests won't run. !!!\n\n")
44 c, err := github.NewClient()
45 if err != nil {
46 log.Fatalf("Error creating GitHub client: %v", err)
47 }
48 client = c
49 } else {
50 c, err := github.NewClient(github.WithAuthToken(token))
51 if err != nil {
52 log.Fatalf("Error creating GitHub client with token: %v", err)
53 }
54 client = c
55 }
56
57 for _, tt := range []struct {
58 url string
59 typ any
60 }{
61 {"users/octocat", &github.User{}},
62 {"user", &github.User{}},
63 {"users/willnorris/keys", &[]github.Key{}},
64 {"orgs/google-test", &github.Organization{}},
65 {"repos/google/go-github", &github.Repository{}},
66 {"repos/google/go-github/issues/1", &github.Issue{}},
67 {"/gists/9257657", &github.Gist{}},
68 } {
69 err := testType(tt.url, tt.typ)
70 if err != nil {
71 fmt.Printf("error: %v\n", err)
72 }
73 }
74}
75
76// testType fetches the JSON resource at urlStr and compares its keys to the
77// struct fields of typ.

Callers

nothing calls this directly

Calls 3

NewClientFunction · 0.92
WithAuthTokenFunction · 0.92
testTypeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…