mirror of
https://git.vectorsigma.ru/public/atlantis.git
synced 2026-07-30 00:27:56 +00:00
Update go-github library
This commit is contained in:
40
vendor/github.com/google/go-github/example/simple/main.go
generated
vendored
Normal file
40
vendor/github.com/google/go-github/example/simple/main.go
generated
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright 2017 The go-github AUTHORS. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// The simple command demonstrates a simple functionality which
|
||||
// prompts the user for a GitHub username and lists all the public
|
||||
// organization memberships of the specified username.
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/google/go-github/v19/github"
|
||||
)
|
||||
|
||||
// Fetch all the public organizations' membership of a user.
|
||||
//
|
||||
func FetchOrganizations(username string) ([]*github.Organization, error) {
|
||||
client := github.NewClient(nil)
|
||||
orgs, _, err := client.Organizations.List(context.Background(), username, nil)
|
||||
return orgs, err
|
||||
}
|
||||
|
||||
func main() {
|
||||
var username string
|
||||
fmt.Print("Enter GitHub username: ")
|
||||
fmt.Scanf("%s", &username)
|
||||
|
||||
organizations, err := FetchOrganizations(username)
|
||||
if err != nil {
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
for i, organization := range organizations {
|
||||
fmt.Printf("%v. %v\n", i+1, organization.GetLogin())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user