githubx

package
v0.0.36 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package githubx provides utilities for interacting with GitHub's API, specifically for fetching information about releases in a GitHub repository.

This package includes functionality to authenticate with GitHub using an OAuth2 token, and to retrieve the latest release information from a specified repository. It leverages the go-github library to interact with GitHub's API.

Example usage:

import (
    "fmt"
    "github.com/yourusername/yourrepo/pkg/githubx"
)

func main() {
    client := githubx.NewGHClient("your-github-token", "owner", "repo")
    latestRelease, err := client.FetchLatestRelease()
    if err != nil {
        fmt.Println("Error fetching latest release:", err)
        return
    }
    fmt.Println("Latest release:", latestRelease)
}

The above example demonstrates how to create a new GHClient instance and fetch the latest release tag from a specified GitHub repository.

Note: Ensure that you have a valid GitHub token with the necessary permissions to access the repository's release information.

For more details on GitHub's API, refer to the official documentation: https://docs.github.com/en/rest/reference/repos#releases

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func (*Client) GetOwner

func (c *Client) GetOwner() string

func (*Client) GetRepo

func (c *Client) GetRepo() string

func (*Client) GetToken

func (c *Client) GetToken() string

type Config

type Config interface {
	GetToken() string
	GetOwner() string
	GetRepo() string
}

func NewClientConfig

func NewClientConfig(owner, repo, token string) Config

type GHClient

type GHClient struct {
	// contains filtered or unexported fields
}

func New

func New(cfg Config) *GHClient

func (*GHClient) FetchLatestRelease

func (gh *GHClient) FetchLatestRelease() (string, error)

FetchLatestRelease fetches the latest release from the GitHub repository.

Returns:

  • A string representing the latest release tag.
  • An error if the latest release cannot be fetched.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL