go-librariesio is a Go client library for accessing the libraries.io API.
go get github.com/hackebrot/go-librariesio/librariesio
Connecting to the libraries.io API with go-librariesio requires a private API key.
// Create new API client with your API key
c := librariesio.NewClient("... your API key ...")
// Create a new context (with a timeout if you want)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()
// Request information about a project using the client
project, _, err := c.Project(ctx, "pypi", "cookiecutter")
if err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
os.Exit(1)
}
// All structs for API resources use pointer values.
// If you expect fields to not be returned by the API
// make sure to check for nil values before dereferencing.
fmt.Printf("name: %v\n", *project.Name)
fmt.Printf("version: %v\n", *project.LatestReleaseNumber)
fmt.Printf("language: %v\n", *project.Language)
Distributed under the terms of the MIT License, go-librariesio is free and open source software.
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
Please check out this guide to get started!
Please note that this project is released with a Contributor Code of Conduct.
By participating in this project you agree to abide by its terms.
Read about why I created go-librariesio in this blog post.