gogithubplus

A Golang module for interacting with GitHub.
RepositoryInfo
RepositoryInfo represents a GitHub repository.
RepositoryInfo members
Name is a string which represents the name of the repository. For example, this repository's name is gogithubplus.
Owner is a string which represents the owner of the repository. For example, this repository's owner is cariad.
RepositoryInfo creation
You can create an instance by calling the Repository(owner string, name string) function:
name is a string which represents the name of the repository. For example, this repository's name is gogithubplus.
owner is a string which represents the owner of the repository. For example, this repository's owner is cariad.
For example:
package main
import (
"fmt"
"github.com/cariad/gogithubplus"
)
func main() {
repository := gogithubplus.Repository("cariad", "gomyrds-createlambda")
fmt.Println(repository.Owner)
// cariad
fmt.Println(repository.Name)
// gomyrds-createlambda
fmt.Println(repository)
// cariad/gomyrds-createlambda
}
RepositoryInfo{}.URL()
The URL() function returns the URL of the repository.
For example:
package main
import (
"fmt"
"github.com/cariad/gogithubplus"
)
func main() {
repository := gogithubplus.Repository("cariad", "gomyrds-createlambda")
fmt.Println(repository.URL())
// https://github.com/cariad/gomyrds-createlambda
}
ReleaseInfo
ReleaseInfo represents a versioned release of a project.
ReleaseInfo members
RepositoryInfo is a RepositoryInfo instance which represents the repository.
Version is a string which which represents the name of the release.
ReleaseInfo creation
You can create an instance by calling the Repository{}.Release(version string) function:
version is a string which which represents the name of the release.
For example:
package main
import (
"fmt"
"github.com/cariad/gogithubplus"
)
func main() {
release := gogithubplus.
Repository("cariad", "gomyrds-createlambda").
Release("v0.1.1")
fmt.Println(release.RepositoryInfo)
// cariad/gomyrds-createlambda
fmt.Println(release.Version)
// v0.1.1
fmt.Println(release)
// cariad/gomyrds-createlambda@v0.1.1
}
ReleaseArtifactInfo
ReleaseArtifactInfo represents a release artifact (e.g. a build).
ReleaseArtifactInfo members
ReleaseInfo is a ReleaseInfo instance which represents the release.
Filename is a string which represents the name of the artifact.
ReleaseArtifactInfo creation
You can create an instance by calling the Release{}.ReleaseArtifact(filename string) function:
filename is a string which represents the name of the artifact.
For example:
package main
import (
"fmt"
"github.com/cariad/gogithubplus"
)
func main() {
artifact := gogithubplus.
Repository("cariad", "gomyrds-createlambda").
Release("v0.1.1").
ReleaseArtifact("gomyrds-createlambda.zip")
fmt.Println(artifact.ReleaseInfo)
// cariad/gomyrds-createlambda@v0.1.1
fmt.Println(artifact.Filename)
// gomyrds-createlambda.zip
}
ReleaseArtifactInfo{}.Download()
The Download() function will download the artifact to your local filesystem.
For example:
package main
import (
"github.com/cariad/gogithubplus"
)
func main() {
artifact := gogithubplus.
Repository("cariad", "gomyrds-createlambda").
Release("v0.1.1").
ReleaseArtifact("gomyrds-createlambda.zip")
artifact.Download("downloaded.zip")
}
ReleaseArtifactInfo implements io.ReadCloser
ReleaseArtifact implements io.ReadCloser so you can read the content as you wish.
For example, you can copy a release artifact to an AWS S3 Bucket without needing to explicitly download it first:
package main
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
"github.com/cariad/gogithubplus"
)
func main() {
artifact := gogithubplus.
Repository("cariad", "gomyrds-createlambda").
Release("v0.1.1").
ReleaseArtifact("gomyrds-createlambda.zip")
defer artifact.Close()
sess, _ := session.NewSessionWithOptions(session.Options{
SharedConfigState: session.SharedConfigEnable,
})
uploader := s3manager.NewUploader(sess)
i := &s3manager.UploadInput{
Body: &artifact,
Bucket: aws.String("my-bucket"),
Key: aws.String("my-lambda.zip"),
}
uploader.Upload(i)
}
This project is published under the MIT Licence.
You don't owe me anything in return, but as an indie freelance coder there are two things I'd appreciate:
- Credit. If your app or documentation has a credits page, please consider mentioning the projects you use.
- Cash. If you want and are able to support future development, please consider becoming a patron or buying me a coffee. Thank you!