Documentation
¶
Index ¶
- func GetReposInfo(user string, token string) ([]utils.RepoNode, error)
- func GetReposName(user string, token string) ([]utils.RepoNode, error)
- func GetUserInfo(username string, token string) (utils.UserInfo, error)
- type CommitByDate
- type CommitsResponse
- type CommitsYear
- type LangPercentage
- type ResponseLangs
- type StreakData
- type StreakPeriod
- type StreakResponse
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetReposInfo ¶
Example ¶
package main
import (
"fmt"
"os"
"github.com/reinanbr/gitinfo"
)
func main() {
token := os.Getenv("GITHUB_TOKEN")
repos, err := gitinfo.GetReposInfo("reinanbr", token)
if err != nil {
fmt.Println("error:", err)
return
}
fmt.Println(len(repos) > 0)
}
Output: true
func GetReposName ¶
Example ¶
package main
import (
"fmt"
"os"
"github.com/reinanbr/gitinfo"
)
func main() {
token := os.Getenv("GITHUB_TOKEN")
repos, err := gitinfo.GetReposName("reinanbr", token)
if err != nil {
fmt.Println("error:", err)
return
}
fmt.Println(len(repos) > 0)
}
Output: true
func GetUserInfo ¶ added in v0.3.1
Example ¶
package main
import (
"fmt"
"os"
"github.com/reinanbr/gitinfo"
)
func main() {
token := os.Getenv("GITHUB_TOKEN")
result, err := gitinfo.GetUserInfo("reinanbr", token)
if err != nil {
fmt.Println("error:", err)
return
}
fmt.Println(result.Login != "")
fmt.Println(result.URL != "")
}
Output: true true
Types ¶
type CommitByDate ¶
type CommitsResponse ¶
type CommitsResponse struct {
User string `json:"user"`
TotalCommits int `json:"totalCommits"`
CommitsByYear []CommitsYear `json:"commitsByYear"`
CommitsByDay []CommitByDate `json:"commitsByDay"`
}
func GetCommits ¶
func GetCommits(username string, token string) (CommitsResponse, error)
Example ¶
package main
import (
"fmt"
"os"
"github.com/reinanbr/gitinfo"
)
func main() {
token := os.Getenv("GITHUB_TOKEN")
result, err := gitinfo.GetCommits("reinanbr", token)
if err != nil {
fmt.Println("error:", err)
return
}
fmt.Println(result.User)
fmt.Println(result.TotalCommits > 0)
fmt.Println(len(result.CommitsByYear) > 0)
fmt.Println(len(result.CommitsByDay) > 0)
}
Output: reinanbr true true true
type CommitsYear ¶
type CommitsYear struct {
Year int `json:"year"`
Commits []CommitByDate `json:"commits"`
}
type LangPercentage ¶
type ResponseLangs ¶
type ResponseLangs struct {
LangPercentages []LangPercentage
TotalBytes int
TotalRepos int
}
func GetLangPercents ¶
func GetLangPercents(username string, token string, ignoreLangs []string) (ResponseLangs, error)
Example ¶
package main
import (
"fmt"
"os"
"github.com/reinanbr/gitinfo"
)
func main() {
token := os.Getenv("GITHUB_TOKEN")
ignoreLangs := []string{"Jupyter Notebook", "TeX"}
result, err := gitinfo.GetLangPercents("reinanbr", token, ignoreLangs)
if err != nil {
fmt.Println("error:", err)
return
}
fmt.Println(result.TotalRepos > 0)
fmt.Println(result.TotalBytes > 0)
fmt.Println(len(result.LangPercentages) > 0)
}
Output: true true true
type StreakData ¶ added in v0.2.0
type StreakData struct {
MaxStreak int `json:"max_streak"`
CurrentStreak int `json:"current_streak"`
MaxStreakPeriod StreakPeriod `json:"max_streak_period"`
CurrentStreakPeriod StreakPeriod `json:"current_streak_period"`
}
type StreakPeriod ¶ added in v0.2.0
type StreakResponse ¶ added in v0.2.0
type StreakResponse struct {
User string `json:"user"`
Streak StreakData `json:"streak"`
}
func GetStreaks ¶
func GetStreaks(username string, token string) (StreakResponse, error)
Example ¶
package main
import (
"fmt"
"os"
"github.com/reinanbr/gitinfo"
)
func main() {
token := os.Getenv("GITHUB_TOKEN")
result, err := gitinfo.GetStreaks("reinanbr", token)
if err != nil {
fmt.Println("error:", err)
return
}
hasUser := result.User != ""
hasStreak := result.Streak.MaxStreak >= 0
fmt.Println(hasUser)
fmt.Println(hasStreak)
}
Output: true true
Click to show internal directories.
Click to hide internal directories.