util

package
v0.21.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2019 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Caller

func Caller() string

Caller returns a caller's call location. If F1 calls F2 which in its turn calls Caller, then this function will return a location within F1 where it calls F2.

func CheckConnection

func CheckConnection(network, ip string, port int, timeout time.Duration) bool

CheckConnection connects to the specified host on the specified port. If the connection is successful then return true.

func ExeDirJoin

func ExeDirJoin(elem ...string) string

ExeDirJoin composes a file name relative to a running executable.

func IsHostname

func IsHostname(s string) bool

IsHostname checks if this is a hostname

func IsIPv4

func IsIPv4(s string) bool

IsIPv4 checks if this is a valid IPv4

func IsNetPort

func IsNetPort(str string) bool

IsNetPort checks if this is a valid net port

func IsTLSCert

func IsTLSCert(block string) bool

IsTLSCert if block is one or more TLS certificates then function returns true

func IsUUID

func IsUUID(s string) bool

IsUUID checks if a given string is a UUID.

func NewUUID

func NewUUID() string

NewUUID generates a new UUID.

func ReadJSONFile

func ReadJSONFile(name string, data interface{}) error

ReadJSONFile reads and parses a JSON file filling a given data instance.

func ReadTestArgs

func ReadTestArgs(args *TestArgs)

ReadTestArgs parses command line and reads arguments.

func RootPath

func RootPath() string

RootPath returns a path of the root package.

func SingleTimeFormat

func SingleTimeFormat(tm time.Time) string

SingleTimeFormat converts time to a string in a single format.

func TestExpectResult

func TestExpectResult(t *testing.T, op string, expected, actual error)

TestExpectResult compares two errors and fails a test if they don't match.

func TestUnmarshalJSON

func TestUnmarshalJSON(t *testing.T, data []byte, v interface{})

TestUnmarshalJSON unmarshals a given JSON into a given object.

func ValidateJSON

func ValidateJSON(schema, data []byte) bool

ValidateJSON validates a given JSON against a given schema.

func WriteJSONFile

func WriteJSONFile(name, prefix, indent string, data interface{}) error

WriteJSONFile converts a given data instance to JSON and writes it to file.

Types

type TestArgs

type TestArgs struct {
	Conf    interface{}
	Verbose bool
}

TestArgs is a test arguments.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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