util

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PermGroupExec         = 0o10
	PermGroupRead         = 0o40
	PermGroupWrite        = 0o20
	PermOtherExec         = 0o1
	PermOtherRead         = 0o4
	PermOtherWrite        = 0o2
	PermUserExec          = 0o100
	PermUserRead          = 0o400
	PermUserReadWriteExec = PermUserExec | PermUserRead | PermUserWrite
	PermUserWrite         = 0o200
)

Constants for file permissions to be combined using `|`.

Variables

View Source
var (
	ErrNoCompilerFound = errors.New("failed to detect compiler")
	ErrInvalidVersion  = errors.New("failed to parse version")
)

Functions

func Aapt2Path added in v1.7.1

func Aapt2Path() (string, error)

Aapt2Path returns the path to aapt2 executable

func AndroidBuildToolsPath

func AndroidBuildToolsPath() string

AndroidBuildToolsPath tries to find the location of the "build-tools" directory. This depends on ANDROID_HOME variable, so you should call RequireAndroidSDK() first.

func CopyExeFile

func CopyExeFile(src, tgt string) error

CopyExeFile copies the content of an executable file, source, into target path.

func CopyFile

func CopyFile(source, target string) error

CopyFile copies the content of a regular file, source, into target path.

func EnsureAbsPath

func EnsureAbsPath(path string) string

EnsureAbsPath returns the absolute path of the given file if it is not already absolute

func EnsureSubDir

func EnsureSubDir(parent, name string) string

EnsureSubDir will make sure a named directory exists within the parent - creating it if not.

func Exists

func Exists(path string) bool

Exists will return true if the passed path exists on the current system.

func ExtractDirFromZip added in v1.7.3

func ExtractDirFromZip(zipPath, prefix, destDir string) error

ExtractDirFromZip extracts all files with a given prefix from a zip archive

func ExtractFileFromZip added in v1.7.3

func ExtractFileFromZip(zipPath, fileName, destPath string) error

ExtractFileFromZip extracts a single file from a zip archive

func ExtractFileFromZipBytes added in v1.7.3

func ExtractFileFromZipBytes(b []byte, fileName, destPath string) error

ExtractFileFromZipReader extracts a single file from an open zip archive handle

func JoinComma added in v1.7.3

func JoinComma(l []string) string

JoinComma takes a list of strings and joins them with comma as separator.

func JoinSpace added in v1.7.3

func JoinSpace(l []string) string

JoinSpace takes a list of strings and joins them with space as separator.

func LookupDirWithGoMod added in v1.7.3

func LookupDirWithGoMod(workDir string) (string, error)

LookupDirWithGoMod takes a directory and checks for a go.mod file, traverses back towards the root, and returns the first directory with a match. In case of a relative path the traversal stops at the relative root

func MakePathRelativeTo

func MakePathRelativeTo(root, path string) string

MakePathRelativeTo joins root with path if path is not absolute and exists in root

func RequireAndroidSDK

func RequireAndroidSDK() error

RequireAndroidSDK will return an error if it cannot establish the location of a valid Android SDK installation. This is currently deduced using ANDROID_HOME environment variable.

func SplitComma added in v1.7.3

func SplitComma(s string) []string

SplitComma returns a slice of strings by splitting then given string by comma.

func SplitDot added in v1.7.3

func SplitDot(s string) []string

SplitDot returns a slice of strings by splitting then given string by dot.

func SplitSlash added in v1.7.3

func SplitSlash(s string) []string

SplitSlash returns a slice of strings by splitting then given string by slash.

func WriteScaledPNG added in v1.7.4

func WriteScaledPNG(src, dst string, size int) error

WriteScaledPNG decodes the PNG at src, scales it to size pixels square and writes it to dst.

Types

type CompilerInfo added in v1.7.3

type CompilerInfo struct {
	Name    string
	Version string
	OS      string
}

CompilerInfo holds detected compiler information.

func DetectCompiler added in v1.7.3

func DetectCompiler(s, os string) (*CompilerInfo, error)

DetectCompiler takes the output of `cc --version` and tries to detect the compiler, compiler version, and os name when available.

Jump to

Keyboard shortcuts

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