util

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OptionalBoolNone a "null" boolean value
	OptionalBoolNone = iota
	// OptionalBoolTrue a "true" boolean value
	OptionalBoolTrue
	// OptionalBoolFalse a "false" boolean value
	OptionalBoolFalse
)

Variables

This section is empty.

Functions

func EnsureAbsolutePath

func EnsureAbsolutePath(path string, absoluteBase string) string

EnsureAbsolutePath ensure that a path is absolute, making it relative to absoluteBase if necessary

func ExistsInSlice

func ExistsInSlice(target string, slice []string) bool

ExistsInSlice returns true if string exists in slice.

func IsEmptyString

func IsEmptyString(s string) bool

IsEmptyString checks if the provided string is empty

func IsEqualSlice

func IsEqualSlice(target []string, source []string) bool

IsEqualSlice returns true if slices are equal.

func IsExternalURL

func IsExternalURL(rawURL string) bool

IsExternalURL checks if rawURL points to an external URL like http://example.com

func IsSliceInt64Eq

func IsSliceInt64Eq(a, b []int64) bool

IsSliceInt64Eq returns if the two slice has the same elements but different sequences.

func Max

func Max(a, b int) int

Max max of two ints

func Min

func Min(a, b int) int

Min min of two ints

func PathEscapeSegments

func PathEscapeSegments(path string) string

PathEscapeSegments escapes segments of a path while not escaping forward slash

func SanitizeMessage

func SanitizeMessage(message, unsanitizedURL string) string

SanitizeMessage sanitizes a message which may contains a sensitive URL

func SanitizeURLCredentials

func SanitizeURLCredentials(unsanitizedURL string, usePlaceholder bool) string

SanitizeURLCredentials sanitizes a url, either removing user credentials or replacing them with a placeholder.

func URLJoin

func URLJoin(base string, elems ...string) string

URLJoin joins url components, like path.Join, but preserving contents

func URLSanitizedError

func URLSanitizedError(err error, unsanitizedURL string) error

URLSanitizedError returns the sanitized version an error whose message may contain a sensitive URL

Types

type Int64Slice

type Int64Slice []int64

Int64Slice attaches the methods of Interface to []int64, sorting in increasing order.

func (Int64Slice) Len

func (p Int64Slice) Len() int

func (Int64Slice) Less

func (p Int64Slice) Less(i, j int) bool

func (Int64Slice) Swap

func (p Int64Slice) Swap(i, j int)

type OptionalBool

type OptionalBool byte

OptionalBool a boolean that can be "null"

func OptionalBoolOf

func OptionalBoolOf(b bool) OptionalBool

OptionalBoolOf get the corresponding OptionalBool of a bool

func (OptionalBool) IsFalse

func (o OptionalBool) IsFalse() bool

IsFalse return true if equal to OptionalBoolFalse

func (OptionalBool) IsNone

func (o OptionalBool) IsNone() bool

IsNone return true if equal to OptionalBoolNone

func (OptionalBool) IsTrue

func (o OptionalBool) IsTrue() bool

IsTrue return true if equal to OptionalBoolTrue

type TimeStamp

type TimeStamp int64

TimeStamp defines a timestamp

func TimeStampNow

func TimeStampNow() TimeStamp

TimeStampNow returns now int64

func (TimeStamp) Add

func (ts TimeStamp) Add(seconds int64) TimeStamp

Add adds seconds and return sum

func (TimeStamp) AddDuration

func (ts TimeStamp) AddDuration(interval time.Duration) TimeStamp

AddDuration adds time.Duration and return sum

func (TimeStamp) AsTime

func (ts TimeStamp) AsTime() (tm time.Time)

AsTime convert timestamp as time.Time in Local locale

func (TimeStamp) AsTimePtr

func (ts TimeStamp) AsTimePtr() *time.Time

AsTimePtr convert timestamp as *time.Time in Local locale

func (TimeStamp) Format

func (ts TimeStamp) Format(f string) string

Format formats timestamp as

func (TimeStamp) FormatLong

func (ts TimeStamp) FormatLong() string

FormatLong formats as RFC1123Z

func (TimeStamp) FormatShort

func (ts TimeStamp) FormatShort() string

FormatShort formats as short

func (TimeStamp) IsZero

func (ts TimeStamp) IsZero() bool

IsZero is zero time

func (TimeStamp) Year

func (ts TimeStamp) Year() int

Year returns the time's year

Jump to

Keyboard shortcuts

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