Documentation ¶
Index ¶
- Variables
- func BoolValueFromEnv(ev string, def bool) bool
- func Contains[K comparable](a []K, x K) bool
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateRandomString(s int) (string, error)
- func IntValueFromEnv(ev string, def int) int
- func Load(path string, v interface{}) error
- func Save(path string, v interface{}) error
- func StringValueFromEnv(ev string, def string) string
- type FallBackWrapper
Constants ¶
This section is empty.
Variables ¶
var Marshal = func(v interface{}) (io.Reader, error) { b, err := json.MarshalIndent(v, "", "\t") if err != nil { return nil, err } return bytes.NewReader(b), nil }
Marshal is a function that marshals the object into an io.Reader. By default, it uses the JSON marshaller.
var Unmarshal = func(r io.Reader, v interface{}) error { return json.NewDecoder(r).Decode(v) }
Unmarshal is a function that unmarshals the data from the reader into the specified value. By default, it uses the JSON unmarshaller.
Functions ¶
func BoolValueFromEnv ¶
BoolValueFromEnv set a value into an *interface from an environment variable or default
func Contains ¶
func Contains[K comparable](a []K, x K) bool
Contains works out if a slice contains a given element
func GenerateRandomBytes ¶
GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GenerateRandomString ¶
GenerateRandomString returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func IntValueFromEnv ¶
IntValueFromEnv set a value into an *interface from an environment variable or default
func Load ¶
Load loads the file at path into v. Use os.IsNotExist() to see if the returned error is due to the file being missing.
func StringValueFromEnv ¶
StringValueFromEnv set a value into an *interface from an environment variable or default
Types ¶
type FallBackWrapper ¶
type FallBackWrapper struct {
Assets http.FileSystem
}
FallBackWrapper serves a file if found and else default to index.html