utils

package
v0.0.0-...-198cc34 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SimpleDateFormat    = "Jan 2"
	SimpleTimeFormat    = "15:04 MST"
	MinimumTimeFormat12 = "3:04 PM"
	MinimumTimeFormat24 = "15:04"
	TimestampFormat     = "2006-01-02T15:04:05-0700"
)

Variables

This section is empty.

Functions

func DigestAvaMsg

func DigestAvaMsg(msg string) []byte

Same algo as Avax wallet msg is the message, returns the hash of the full msg with prefix

func DoesNotInclude

func DoesNotInclude(strs []string, val string) bool

DoesNotInclude takes a slice of strings and a target string and returns TRUE if the slice does not include the target, FALSE if it does

Example:

x := DoesNotInclude([]string{"cat", "dog", "rat"}, "dog")
> false

x := DoesNotInclude([]string{"cat", "dog", "rat"}, "pig")
> true

func Dump

func Dump(obj interface{}) string

func EnsureFullPath

func EnsureFullPath(path string, mod os.FileMode)

EnsureFullPath ensures a directory exist from the given path.

func EnsurePath

func EnsurePath(path string, mod os.FileMode)

EnsurePath ensures a directory exist from the given path.

func Fatalf

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

Fatalf formats a message to standard error and exits the program. The message is also printed to standard output if standard error is redirected to a different file.

func FindMatch

func FindMatch(pattern string, data string) [][]string

FindMatch takes a regex pattern and a string of data and returns back all the matches in that string

func Includes

func Includes(strs []string, val string) bool

Includes takes a slice of strings and a target string and returns TRUE if the slice includes the target, FALSE if it does not

Example:

x := Includes([]string{"cat", "dog", "rat"}, "dog")
> true

x := Includes([]string{"cat", "dog", "rat"}, "pig")
> false

func MustGetUser

func MustGetUser() string

MustGetUser establishes current user identity or fail.

func PublicKeyFromAvaMsg

func PublicKeyFromAvaMsg(msg string, avasigcb58 string) (avacrypto.PublicKey, error)

Validate a msg signed with the Avalanche web wallet "Sign Message" feature

func ReadFileBytes

func ReadFileBytes(filePath string) ([]byte, error)

ReadFileBytes reads the contents of a file and returns those contents as a slice of bytes

func SigToRS

func SigToRS(sig mpsecdsa.Signature) (big.Int, big.Int)

Useful for using standard ecdsa funcs that require int args

Types

type StringSet

type StringSet map[string]struct{}

https://github.com/ungerik/go-dry/blob/master/string.go StringSet wraps map[string]struct{} with some useful methods. TODO use this for wallets / users etc

func (StringSet) Clone

func (set StringSet) Clone() StringSet

func (StringSet) Delete

func (set StringSet) Delete(s string)

func (StringSet) Exclude

func (set StringSet) Exclude(other StringSet)

func (StringSet) Has

func (set StringSet) Has(s string) bool

func (StringSet) Join

func (set StringSet) Join(other StringSet)

func (StringSet) ReverseSorted

func (set StringSet) ReverseSorted() []string

func (StringSet) Set

func (set StringSet) Set(s string)

func (StringSet) Sorted

func (set StringSet) Sorted() []string

Jump to

Keyboard shortcuts

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