Skip to content

Instantly share code, notes, and snippets.

@hackerzhut
Created December 16, 2022 14:35
Show Gist options
  • Save hackerzhut/72a7919bfec11168f63a94a9036d1431 to your computer and use it in GitHub Desktop.
Save hackerzhut/72a7919bfec11168f63a94a9036d1431 to your computer and use it in GitHub Desktop.
find language of the repo - github
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