Back to godoc.org

Package common

v0.0.0-...-d4e899e
Latest Go to latest

The highest tagged major version is .

Published: Jul 17, 2020 | License: MIT | Module: forge.grandlyon.com/apoyen/sdk-go

Index

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.

func Contains

func Contains(a []string, x string) bool

Contains works out if a string slice contains a given string element

func GenerateRandomBytes

func GenerateRandomBytes(n int) ([]byte, error)

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

func GenerateRandomString(s int) (string, error)

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 Load

func Load(path string, v interface{}) error

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 Save

func Save(path string, v interface{}) error

Save saves a representation of v to the file at path.

type FallBackWrapper

type FallBackWrapper struct {
	Assets http.FileSystem
}

FallBackWrapper serves a file if found and else default to index.html

func (*FallBackWrapper) Open

func (i *FallBackWrapper) Open(name string) (http.File, error)

Open serves a file if found and else default to index.html

Package Files

  • common.go
Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier