types

package
v1.5.17 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2025 License: Apache-2.0 Imports: 10 Imported by: 6

Documentation

Index

Constants

View Source
const (
	SchemeSecure            = "https"
	SchemeInsecure          = "http"
	ContentTypeHeader       = "Content-Type"
	ContentAcceptHeader     = "Accept"
	ContentLengthHeader     = "Content-Length"
	ContentDispositonHeader = "Content-Disposition"
	ContentModifiedHeader   = "Last-Modified"
	ContentHashHeader       = "ETag"
)
View Source
const (
	ContentTypeJSON       = "application/json"
	ContentTypeXML        = "application/xml"
	ContentTypeRSS        = "application/rss+xml"
	ContentTypeBinary     = "application/octet-stream"
	ContentTypeCSV        = "text/csv"
	ContentTypeTextXml    = "text/xml"
	ContentTypeTextPlain  = "text/plain"
	ContentTypeTextStream = "text/event-stream"
	ContentTypeFormData   = "multipart/form-data"
	ContentTypeAny        = "*/*"
)
View Source
const (
	// An identifier is a string which starts with a letter and is followed by
	// letters, numbers, underscores or hyphens. It must be between 1 and 64 characters
	ReIdentifier = `[a-zA-Z][a-zA-Z0-9_\-]{0,63}`
)

Variables

This section is empty.

Functions

func AcceptContentType added in v1.5.0

func AcceptContentType(r *http.Request) (string, error)

func BoolPtr added in v1.5.0

func BoolPtr(v bool) *bool

BoolPtr returns a pointer to a bool

func DoubleQuote added in v1.5.0

func DoubleQuote(str string) string

DoubleQuote returns a string with the input string quoted and escaped for

func DurationPtr added in v1.5.0

func DurationPtr(v time.Duration) *time.Duration

DurationPtr returns a pointer to a time.Duration

func Float64Ptr added in v1.5.6

func Float64Ptr(v float64) *float64

Float64Ptr returns a pointer to a float64

func Hash added in v1.5.12

func Hash(data []byte) string

func Int32Ptr added in v1.5.4

func Int32Ptr(v int32) *int32

Int32Ptr returns a pointer to a int32

func Int64Ptr added in v1.5.4

func Int64Ptr(v int64) *int64

Int64Ptr returns a pointer to a int64

func IsDoubleQuoted added in v1.5.0

func IsDoubleQuoted(s string) bool

IsDoubleQuoted checks if a string is double-quoted

func IsEmail added in v1.5.0

func IsEmail(addr string, name, email *string) bool

Parse an email address into a name and address parts, and return true if the email address is valid

func IsIdentifier

func IsIdentifier(s string) bool

Return true if the string is a valid identifier

func IsNumeric added in v1.5.0

func IsNumeric(s string) bool

IsNumeric checks if a string consists only of digits

func IsSingleQuoted added in v1.5.0

func IsSingleQuoted(s string) bool

IsSingleQuoted checks if a string is single-quoted

func IsUUID added in v1.5.0

func IsUUID(id string) bool

Return true if the string is a valid UUID

func IsUppercase added in v1.5.0

func IsUppercase(s string) bool

IsUppercase checks if a string is all in uppercase (A-Z)

func JoinPath added in v1.5.0

func JoinPath(prefix, path string) string

Return a normalised joined path

func NormalisePath added in v1.5.0

func NormalisePath(path string) string

Return path with a single '/' separator at the beginning and no trailing '/' separator

func ParseContentType added in v1.5.0

func ParseContentType(header string) (string, error)

Parse a content type header to return the mimetype

func PtrBool added in v1.5.0

func PtrBool(v *bool) bool

PtrBool returns a bool from a pointer

func PtrDuration added in v1.5.5

func PtrDuration(v *time.Duration) time.Duration

PtrDuration returns a duration from a pointer

func PtrFloat64 added in v1.5.6

func PtrFloat64(v *float64) float64

PtrFloat64 returns a float64 from a pointer

func PtrInt32 added in v1.5.4

func PtrInt32(v *int32) int32

PtrInt32 returns a int32 from a pointer

func PtrInt64 added in v1.5.4

func PtrInt64(v *int64) int64

PtrInt64 returns a int64 from a pointer

func PtrString added in v1.5.0

func PtrString(s *string) string

PtrString returns a string from a pointer

func PtrTime added in v1.5.0

func PtrTime(t *time.Time) time.Time

PtrTime returns a time.Time from a pointer

func PtrUint64 added in v1.5.0

func PtrUint64(v *uint64) uint64

PtrUint64 returns a uint64 from a pointer

func Quote added in v1.5.0

func Quote(str string) string

Quote returns a string with the input string quoted and escaped for

func RequestContentType added in v1.5.0

func RequestContentType(r *http.Request) (string, error)

func StringPtr added in v1.5.0

func StringPtr(s string) *string

StringPtr returns a pointer to a string

func TimePtr added in v1.5.5

func TimePtr(t time.Time) *time.Time

PtrTime returns a pointer to a time.Time

func TrimStringPtr added in v1.5.5

func TrimStringPtr(s *string) *string

TrimStringPtr returns a pointer to a white-space trimmed string, or nil if the string is empty

func UUIDSplit added in v1.5.0

func UUIDSplit(id string) []string

Return two-byte parts of a UUID, or nil if the UUID is invalid. The function will always return eight sets if the UUID is valid.

func Uint64Ptr added in v1.5.0

func Uint64Ptr(v uint64) *uint64

Uint64Ptr returns a pointer to a uint64

func Unquote added in v1.5.4

func Unquote(s string) string

Unquote returns a string with the input string unquoted

Types

This section is empty.

Jump to

Keyboard shortcuts

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