util

package
v1.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GoBuildIgnoreComment = "//go:build ignore"
	GoModFile            = "go.mod"
	GoSumFile            = "go.sum"
	GoWorkSumFile        = "go.work.sum"
	DebugLogFile         = "debug.log"
	TempBuildDir         = ".otel-build"
)
View Source
const (
	BuildPattern    = "-p"
	BuildImportPath = "-importpath"
	BuildGoVer      = "-goversion"
	BuildPgoProfile = "-pgoprofile"
	BuildModeVendor = "-mod=vendor"
	BuildModeMod    = "-mod=mod"
	BuildWork       = "-work"
)
View Source
const (
	PInvalid    = "invalid"
	PPreprocess = "preprocess"
	PInstrument = "instrument"
)

Variables

View Source
var Guarantee = Assert // More meaningful name:)

Functions

func Assert

func Assert(condition bool, message string)

func AssertGoBuild

func AssertGoBuild(args []string)

func AssertType

func AssertType[T any](v any) T

func CopyDir

func CopyDir(src string, dst string) error

func CopyDirExclude

func CopyDirExclude(src string, dst string, exclude []string) error

func CopyFile

func CopyFile(src, dst string) error

func Crc32

func Crc32(s string) string

func FindFlagValue

func FindFlagValue(cmd []string, flag string) string

func GetInstrumentLogPath

func GetInstrumentLogPath(name string) string

func GetLogPath

func GetLogPath(name string) string

func GetLoggerPath

func GetLoggerPath() string

func GetMatchedRuleFile

func GetMatchedRuleFile() string

func GetPreprocessLogPath

func GetPreprocessLogPath(name string) string

func GetTempBuildDir

func GetTempBuildDir() string

func GetTempBuildDirWith

func GetTempBuildDirWith(name string) string

func GetToolName

func GetToolName() (string, error)

func GetVarNameOfFunc

func GetVarNameOfFunc(fn string) string

func HasGoBuildComment

func HasGoBuildComment(text string) bool

func InInstrument

func InInstrument() bool

func InPreprocess

func InPreprocess() bool

func IsCgo1GoFile

func IsCgo1GoFile(path string) bool

func IsCgoCommand

func IsCgoCommand(line string) bool

func IsCompileCommand

func IsCompileCommand(line string) bool

func IsGoFile

func IsGoFile(path string) bool

func IsGoModFile

func IsGoModFile(path string) bool

func IsGoSumFile

func IsGoSumFile(path string) bool

func IsGoTestFile

func IsGoTestFile(path string) bool

func IsModPath

func IsModPath(path string) bool

IsModPath checks if the provided module path is valid.

func IsUnix

func IsUnix() bool

func IsWindows

func IsWindows() bool

func Jsonify

func Jsonify(v interface{}) string

func ListFiles

func ListFiles(dir string) ([]string, error)

func Log

func Log(format string, args ...interface{})

func PathExists

func PathExists(path string) bool

func PathNotExists

func PathNotExists(path string) bool

func PhaseTimer

func PhaseTimer(name string) func()

func ReadFile

func ReadFile(filePath string) (string, error)

func RemoveGoBuildComment

func RemoveGoBuildComment(text string) string

func RenamePackage

func RenamePackage(source, newPkgName string) string

func RunCmd

func RunCmd(args ...string) error

func SetLogger

func SetLogger(w *os.File)

Be caution it's not thread safe

func SetRunPhase

func SetRunPhase(phase RunPhase)

func ShouldNotReachHere

func ShouldNotReachHere()

func SplitCompileCmds

func SplitCompileCmds(input string) []string

SplitCompileCmds splits the command line by space, but keep the quoted part as a whole. For example, "a b" c will be split into ["a b", "c"].

func Unimplemented

func Unimplemented(message string)

func WriteFile

func WriteFile(filePath string, content string) (string, error)

Types

type RunPhase

type RunPhase string

func GetRunPhase

func GetRunPhase() RunPhase

func (RunPhase) String

func (rp RunPhase) String() string

Jump to

Keyboard shortcuts

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