helper

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: MIT Imports: 22 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadToCache

func DownloadToCache(src string) (string, error)

func ExtractArchive

func ExtractArchive(src, dest string) error

func FileAppendLine

func FileAppendLine(filename string, fileperm os.FileMode, line string) error

func FileExists

func FileExists(path string) bool

func FileLastRune

func FileLastRune(filename string) (rune, error)

func FileLineExists

func FileLineExists(filename, targetLine string) bool

func FileNameModify

func FileNameModify(target string, fn func(string) []string) []string

func FileNameModifyReplace

func FileNameModifyReplace(from string, to ...string) func(string) []string

func FilesMatch

func FilesMatch(baseDir, pattern string) []string

func FilterCoverageOutput

func FilterCoverageOutput(filename string) error

FilterCoverageOutput filters the coverage output by removing any lines that contain generated protobuf files `.pg.go`.

func GetEnv

func GetEnv(key, fallback string) string

GetEnv returns an environment variable value if present, or a default value.

func GetModuleName

func GetModuleName() (string, error)

func GetProtobufVersion

func GetProtobufVersion() string

func GitHash

func GitHash() string

func GitHeadRev

func GitHeadRev() string

func GitHeadTag

func GitHeadTag() string

func GitSlug

func GitSlug() string

func HTTPGetLatestGitHubVersion

func HTTPGetLatestGitHubVersion(slug string) (string, error)

func HTTPWriteFile

func HTTPWriteFile(rawURL, filename string, fileperm os.FileMode) error

func LDFlags

func LDFlags(debug bool) []string

func MustCommandPaths

func MustCommandPaths() []string

func MustGetGoBin

func MustGetGoBin() string

MustGetGoBin get GOBIN.

if GOBIN is not set then attempt to derive its value using GOPATH.

if GOPATH is not set, use (pwd)/artifacts/bin .

func MustGetHomeDir

func MustGetHomeDir(filename ...string) string

MustGetHomeDir get user home directory or panic if unable to.

func MustGetOutput

func MustGetOutput(cmd string) string

func MustGetProtobufPath

func MustGetProtobufPath() string

func MustGetWD

func MustGetWD(filename ...string) string

MustGetWD get working directory or panic if unable to.

func MustMakeDir

func MustMakeDir(path string, fileperm os.FileMode)

MustMakeDir make directory, including parents if required.

if unable to make directory then panic.

func PanicIfError

func PanicIfError(err error, prependStr string)

PanicIfError panics if passed error is not nil.

prependStr is optional string to prepend to panic error.

func PrintDebug

func PrintDebug(format string, v ...any)

PrintDebug prints the passed debug message to stdout in white text with blue chevron.

func PrintInfo

func PrintInfo(format string, v ...any)

PrintInfo prints the passed info message to stdout in white text with green chevron.

func PrintWarning

func PrintWarning(format string, v ...any)

PrintWarn prints the passed warning message to stdout in white text with yellow chevron.

func ProtobufIncludePaths

func ProtobufIncludePaths() []string

func ProtobufTargets

func ProtobufTargets() []string

func SanitizeArchivePath

func SanitizeArchivePath(d, t string) (string, error)

Sanitize archive file pathing from "G305: Zip Slip vulnerability".

func SetEnv

func SetEnv(key, value string) func()

func TargetNeedRefresh

func TargetNeedRefresh(target string, src ...string) bool

func Unzip

func Unzip(src, dest string) error

Types

type CommandEnv

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

func (*CommandEnv) Revert

func (e *CommandEnv) Revert()

type CommandTemplate

type CommandTemplate struct {
	Debug bool

	CGO    string
	GoOS   string
	GoArch string
	GoArm  string

	GitRev     string
	GitHash    string
	GitHeadTag string
	GitSlug    string

	LDFlags string

	CWD string

	OutputArtifact string
	TargetPath     string
	CommandDir     string
	CommandName    string
	HomeDir        string
}

func NewCommandTemplate

func NewCommandTemplate(debug bool, commandDir string) *CommandTemplate

func (*CommandTemplate) Render

func (t *CommandTemplate) Render(cmd string) (string, error)

type Module

type Module struct {
	Path       string       `json:"Path"`       // module path
	Query      string       `json:"Query"`      // version query corresponding to this version
	Version    string       `json:"Version"`    // module version
	Versions   []string     `json:"Versions"`   // available module versions
	Replace    *Module      `json:"Replace"`    // replaced by this module
	Time       *time.Time   `json:"Time"`       // time version was created
	Update     *Module      `json:"Update"`     // available update (with -u)
	Main       bool         `json:"Main"`       // is this the main module?
	Indirect   bool         `json:"Indirect"`   // module is only indirectly needed by main module
	Dir        string       `json:"Dir"`        // directory holding local copy of files, if any
	GoMod      string       `json:"GoMod"`      // path to go.mod file describing module, if any
	GoVersion  string       `json:"GoVersion"`  // go version used in module
	Retracted  []string     `json:"Retracted"`  // retraction information, if any (with -retracted or -u)
	Deprecated string       `json:"Deprecated"` // deprecation message, if any (with -u)
	Error      *ModuleError `json:"Error"`      // error loading module
	Origin     any          `json:"Origin"`     // provenance of module
	Reuse      bool         `json:"Reuse"`      // reuse of old module info is safe
}

func GolangListModules

func GolangListModules() ([]Module, error)

type ModuleError

type ModuleError struct {
	Err string `json:"Err"` // the error itself
}

Jump to

Keyboard shortcuts

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