Skip to content

andygrunwald/go-trending

Repository files navigation

go-trending

GoDoc Go Report Card

A package to retrieve trending repositories and developers from Github written in Go.

trending package showcase

Features

  • Get trending repositories
  • Get trending developers
  • Get all programming languages known by GitHub
  • Filtering by time and (programming) language
  • Support for GitHub Enterprise

Installation

It is go gettable

$ go get github.com/andygrunwald/go-trending

or using/updating to the latest master

$ go get -u github.com/andygrunwald/go-trending@master

API

Please have a look at the package documentation for a detailed API description.

Examples

A few examples how the API can be used. More examples are available in the GoDoc examples section.

List trending repositories of today for all languages

package main

import (
	"fmt"

	"github.com/andygrunwald/go-trending"
)

func main() {
	trend := trending.NewTrending()

	// Show projects of today
	projects, err := trend.GetProjects(trending.TimeToday, "")
	if err != nil {
		panic(err)
	}

	for index, project := range projects {
		i := index + 1
		if len(project.Language) > 0 {
			fmt.Printf("%d: %s (written in %s with %d ★ )\n", i, project.Name, project.Language, project.Stars)
		} else {
			fmt.Printf("%d: %s (with %d ★ )\n", i, project.Name, project.Stars)
		}
	}
}

List trending repositories of this week for Go

package main

import (
	"fmt"

	"github.com/andygrunwald/go-trending"
)

func main() {
	trend := trending.NewTrending()

	// Show projects of today
	projects, err := trend.GetProjects(trending.TimeWeek, "go")
	if err != nil {
		panic(err)
	}

	for index, project := range projects {
		i := index + 1
		if len(project.Language) > 0 {
			fmt.Printf("%d: %s (written in %s with %d ★ )\n", i, project.Name, project.Language, project.Stars)
		} else {
			fmt.Printf("%d: %s (with %d ★ )\n", i, project.Name, project.Stars)
		}
	}
}

List trending developers of this month for Swift

package main

import (
	"fmt"

	"github.com/andygrunwald/go-trending"
)

func main() {
	trend := trending.NewTrending()

	developers, err := trend.GetDevelopers(trending.TimeMonth, "swift")
	if err != nil {
		panic(err)
	}

	for index, developer := range developers {
		i := index + 1
		fmt.Printf("%d: %s (%s)\n", i, developer.DisplayName, developer.FullName)
	}
}

List available languages

package main

import (
	"fmt"

	"github.com/andygrunwald/go-trending"
)

func main() {
	trend := trending.NewTrending()

	// Show languages
	languages, err := trend.GetLanguages()
	if err != nil {
		panic(err)
	}

	for index, language := range languages {
		i := index + 1
		fmt.Printf("%d: %s (%s)\n", i, language.Name, language.URLName)
	}
}

Inspired by

License

This project is released under the terms of the MIT license.

About

Go library for accessing trending repositories and developers at Github.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published