| 153 | } |
| 154 | |
| 155 | func ExampleTeamsService_ListTeams() { |
| 156 | // This example shows how to get a team ID corresponding to a given team name. |
| 157 | |
| 158 | // Note that authentication is needed here as you are performing a lookup on |
| 159 | // an organization's administrative configuration, so you will need to modify |
| 160 | // the example to to provide authentication to github.NewClient(). See the |
| 161 | // following documentation for more information on how to authenticate with |
| 162 | // the client: |
| 163 | // https://pkg.go.dev/github.com/google/go-github/v88/github#hdr-Authentication |
| 164 | client, err := github.NewClient() |
| 165 | if err != nil { |
| 166 | log.Fatalf("Error creating GitHub client: %v", err) |
| 167 | } |
| 168 | |
| 169 | teamName := "Developers team" |
| 170 | ctx := context.Background() |
| 171 | opts := &github.ListOptions{} |
| 172 | |
| 173 | for { |
| 174 | teams, resp, err := client.Teams.ListTeams(ctx, "myOrganization", opts) |
| 175 | if err != nil { |
| 176 | log.Fatalf("error listing teams: %v", err) |
| 177 | } |
| 178 | for _, t := range teams { |
| 179 | if t.GetName() == teamName { |
| 180 | fmt.Printf("Team %q has ID %v\n", teamName, t.GetID()) |
| 181 | return |
| 182 | } |
| 183 | } |
| 184 | if resp.NextPage == 0 { |
| 185 | break |
| 186 | } |
| 187 | opts.Page = resp.NextPage |
| 188 | } |
| 189 | |
| 190 | fmt.Printf("Team %q was not found\n", teamName) |
| 191 | } |
| 192 | |
| 193 | func ExampleUsersService_ListUserSocialAccounts() { |
| 194 | client, err := github.NewClient() |