util

package
v1.4.430 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTokenFromEnv

func GetTokenFromEnv(tokenValue string) string

GetTokenFromEnv returns a GitHub token based on the following precedence order:

  1. If tokenValue is non-empty, it is returned.
  2. Otherwise, if the GITHUB_TOKEN environment variable is set, its value is returned.
  3. Otherwise, if the GH_TOKEN environment variable is set, its value is returned.
  4. If none of the above are set, an empty string is returned.

Example:

os.Setenv("GITHUB_TOKEN", "abc")
os.Setenv("GH_TOKEN", "def")
GetTokenFromEnv("xyz") // returns "xyz"
GetTokenFromEnv("")    // returns "abc"
os.Unsetenv("GITHUB_TOKEN")
GetTokenFromEnv("")    // returns "def"
os.Unsetenv("GH_TOKEN")
GetTokenFromEnv("")    // returns ""

Types

This section is empty.

Jump to

Keyboard shortcuts

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