Help us shape the future of Go! Take the 2026 Go Developer Survey

github

package
v1.58.8 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package github provides utilities for interacting with GitHub repositories.

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyTree = errors.New("empty tree")

Functions

func ExtractTree

func ExtractTree(ctx context.Context, tree *Tree, dst string) error

ExtractTree downloads a (sub-)tree from a GitHub repository and writes it to dst.

Types

type Tree

type Tree struct {
	Owner  string // GitHub owner (user or organization)
	Repo   string // repository name
	Branch string // branch name
	Path   string // path to subtree ("." for whole project)
}

Tree contains information about a (sub-)tree in a GitHub repository.

func ParseTree

func ParseTree(ctx context.Context, s string) (*Tree, error)

ParseTree parses a GitHub repository URL into a Tree.

Valid URLs are: - github.com/owner/repo - github.com/owner/repo/tree/<branch> - github.com/owner/repo/tree/<branch>/<path>

If the URL does not contain a branch, the default branch is queried using GitHub's API.

func (*Tree) Name

func (t *Tree) Name() string

Name reports a suitable name of the top-level directory in the tree. It defaults to the repository name, unless a Path is given in which case it is the last component of the path.

Jump to

Keyboard shortcuts

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