Created
December 16, 2022 14:35
-
-
Save hackerzhut/72a7919bfec11168f63a94a9036d1431 to your computer and use it in GitHub Desktop.
find language of the repo - github
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"fmt" | |
"github.com/google/go-github/v32/github" | |
"golang.org/x/oauth2" | |
) | |
func main() { | |
ctx := context.Background() | |
ts := oauth2.StaticTokenSource( | |
&oauth2.Token{AccessToken: "YOUR_ACCESS_TOKEN"}, | |
) | |
tc := oauth2.NewClient(ctx, ts) | |
client := github.NewClient(tc) | |
// Replace "OWNER" and "REPO" with the owner and repository name | |
repo, _, err := client.Repositories.Get(ctx, "OWNER", "REPO") | |
if err != nil { | |
fmt.Printf("Error fetching repository: %v\n", err) | |
return | |
} | |
// The language field in the repository response contains the primary language | |
// of the repository. | |
language := *repo.Language | |
fmt.Printf("Primary language of repository: %s\n", language) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment