util

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlwaysLog

func AlwaysLog(msg string)

AlwaysLog logs message either in verbose mode or not.

func AlwaysLogf

func AlwaysLogf(msg string, v ...interface{})

AlwaysLogf logs message either in verbose mode or not.

func ExecOutput

func ExecOutput(cmd string, args ...string) (string, error)

ExecOutput executes a command and returns its standard output

func GitCmd

func GitCmd() string

GitCmd reports the command to use to extract git info. By default it is the "go" binary in the PATH.

func GoCmd

func GoCmd() string

GoCmd reports the command to use to build go code. By default it is the "go" binary in the PATH.

func Log

func Log(msg string)

Log logs message if verbose mode is on.

func Logf

func Logf(msg string, v ...interface{})

Logf logs message if verbose mode is on.

func Md5

func Md5(file string) (string, error)

Md5 returns md5sum for the given file

func RunCmd

func RunCmd(name string, arg ...string) error

RunCmd runs the given command displaying its standard output if in verbose mode

func Sha1

func Sha1(file string) (string, error)

Sha1 returns sha1sum for the given file

func Sha256

func Sha256(file string) (string, error)

Sha256 returns sha256sum for the given file

func TarFiles

func TarFiles(filename string, files []string, preserveDir bool) error

From https://www.arthurkoziel.com/writing-tar-gz-files-in-go/

func TrimString

func TrimString(val string) string

TrimString trims string for: ' ', '"', '\n'

func Verbose

func Verbose() bool

Verbose reports whether a magefile was run with the verbose flag.

func ZipFiles

func ZipFiles(filename string, files []string) error

ZipFiles compresses one or many files into a single zip archive file. The original code was published under MIT licence under https://golangcode.com/create-zip-files-in-go/

Types

type ChecksumDetails

type ChecksumDetails struct {
	Md5    string
	Sha1   string
	Sha256 string
}

ChecksumDetails provides check sums

func GetChecksumDetails

func GetChecksumDetails(filePath string) (ChecksumDetails, error)

GetChecksumDetails returns file checksums for a given file

type FileDetails

type FileDetails struct {
	Checksum ChecksumDetails
	Size     int64
}

FileDetails provides check sums and size for a given file

func GetFileDetails

func GetFileDetails(filePath string) (*FileDetails, error)

GetFileDetails returns file details for a given file

Jump to

Keyboard shortcuts

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