utils

package
v0.0.0-...-6492cd3 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func B64ToHex

func B64ToHex(data string) (string, error)

B64ToHex converts a base64 encoded string to a hexadecimal string. It returns an error if the string provided is not a valid base64 string.

func ComputeB64MD5

func ComputeB64MD5(data []byte) string

ComputeB64MD5 computes the MD5 hash of the given data and returns the result as a base64 encoded string.

func ComputeFileB64MD5

func ComputeFileB64MD5(path string) (string, error)

ComputeFileB64MD5 computes the MD5 hash of the file at the given path and returns the result as a base64 encoded string. It returns an error if the file cannot be opened or read.

func CopyFile

func CopyFile(src, dst string) error

CopyFile copies the contents of `src` into `dst`.

If the source doesn't exist this is a no-op and an error is returned.

If the destination exists, it will be overwritten.

This operation is not atomic: if either the source or destination files are modified during the copy, the destination file's contents may be corrupted.

func FileExists

func FileExists(path string) (bool, error)

func GenerateAlphanumericSequence

func GenerateAlphanumericSequence(length int) string

func HexToB64

func HexToB64(data string) (string, error)

HexToB64 converts a hexadecimal string to a base64 encoded string. It returns an error if the string provided is not valid hexadecimal.

func NilIfZero

func NilIfZero[T comparable](x T) *T

func PrintFooterOffline

func PrintFooterOffline(settings *service.Settings)

func PrintFooterOnline

func PrintFooterOnline(run *service.RunRecord, settings *service.Settings)

func PrintHeadFoot

func PrintHeadFoot(run *service.RunRecord, settings *service.Settings, footer bool)

This is used by the go wandb client to print the header and footer of the run

func ShortID

func ShortID(length int) string

func VerifyFileHash

func VerifyFileHash(path string, b64md5 string) bool

VerifyFileHash checks if file at the given path matches the MD5 hash provided as a base64 encoded string. It returns true if the file is present and matches the hash, false otherwise -- including if the file is missing, a directory, or can't be read.

func WriteJsonToFileWithDigest

func WriteJsonToFileWithDigest(marshallable interface{}) (filename string, digest string, size int64, rerr error)

func ZeroIfNil

func ZeroIfNil[T comparable](x *T) T

Types

This section is empty.

Jump to

Keyboard shortcuts

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