Documentation
¶
Overview ¶
Package ghtoken resolves a GitHub API token from the environment or, as a fallback, from the locally installed GitHub CLI (`gh`).
Resolution order:
- GITHUB_TOKEN env var (legacy, CI, scripts).
- GH_TOKEN env var (gh CLI's own override).
- `gh auth token` if `gh` is on PATH AND the user is authenticated.
This means a developer who has `gh auth login`'d once never has to set GITHUB_TOKEN by hand — releases, asset uploads, and remote repo creation all "just work".
All resolution is best-effort: when no source yields a token, an empty string + a typed reason are returned so callers can render a user-friendly message instead of a stack trace.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNoToken = errors.New("no GitHub token available (set GITHUB_TOKEN or run `gh auth login`)")
ErrNoToken is returned by Resolve when neither env vars nor the gh CLI yield a usable token. Wrapped so callers can branch on errors.Is without losing the human-readable detail.
Functions ¶
This section is empty.