types

package
v1.6.9 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 11 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

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

func BoolPtr deprecated

func BoolPtr(v bool) *bool

BoolPtr returns a pointer to a bool.

Deprecated: Use Ptr instead.

func DoubleQuote

func DoubleQuote(str string) string

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

func DurationPtr deprecated

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

DurationPtr returns a pointer to a time.Duration.

Deprecated: Use Ptr instead.

func Float64Ptr deprecated

func Float64Ptr(v float64) *float64

Float64Ptr returns a pointer to a float64.

Deprecated: Use Ptr instead.

func Hash

func Hash(data []byte) string

func Int32Ptr deprecated

func Int32Ptr(v int32) *int32

Int32Ptr returns a pointer to an int32.

Deprecated: Use Ptr instead.

func Int64Ptr deprecated

func Int64Ptr(v int64) *int64

Int64Ptr returns a pointer to an int64.

Deprecated: Use Ptr instead.

func IsDoubleQuoted

func IsDoubleQuoted(s string) bool

IsDoubleQuoted checks if a string is double-quoted

func IsEmail

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

func IsNumeric(s string) bool

IsNumeric checks if a string consists only of digits

func IsSingleQuoted

func IsSingleQuoted(s string) bool

IsSingleQuoted checks if a string is single-quoted

func IsUUID

func IsUUID(id string) bool

Return true if the string is a valid UUID

func IsUppercase

func IsUppercase(s string) bool

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

func JoinPath

func JoinPath(prefix, path string) string

Return a normalised joined path

func NormalisePath

func NormalisePath(path string) string

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

func ParseContentType

func ParseContentType(header string) (string, error)

Parse a content type header to return the mimetype

func Ptr

func Ptr[T any](v T) *T

Ptr returns a pointer to a value

func PtrBool deprecated

func PtrBool(v *bool) bool

PtrBool returns a bool from a pointer.

Deprecated: Use Value instead.

func PtrDuration deprecated

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

PtrDuration returns a duration from a pointer.

Deprecated: Use Value instead.

func PtrFloat64 deprecated

func PtrFloat64(v *float64) float64

PtrFloat64 returns a float64 from a pointer.

Deprecated: Use Value instead.

func PtrInt32 deprecated

func PtrInt32(v *int32) int32

PtrInt32 returns an int32 from a pointer.

Deprecated: Use Value instead.

func PtrInt64 deprecated

func PtrInt64(v *int64) int64

PtrInt64 returns an int64 from a pointer.

Deprecated: Use Value instead.

func PtrString deprecated

func PtrString(s *string) string

PtrString returns a string from a pointer.

Deprecated: Use Value instead.

func PtrTime deprecated

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

PtrTime returns a time.Time from a pointer.

Deprecated: Use Value instead.

func PtrUint64 deprecated

func PtrUint64(v *uint64) uint64

PtrUint64 returns a uint64 from a pointer.

Deprecated: Use Value instead.

func Quote

func Quote(str string) string

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

func RequestContentType

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

func StringPtr deprecated

func StringPtr(s string) *string

StringPtr returns a pointer to a string.

Deprecated: Use Ptr instead.

func Stringify

func Stringify[T any](v T) string

Stringify returns a JSON representation of the input value

func TimePtr deprecated

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

TimePtr returns a pointer to a time.Time, or nil if zero.

Deprecated: Use Ptr instead (note: Ptr does not nil-on-zero).

func TrimStringPtr

func TrimStringPtr(s *string) *string

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

func UUIDSplit

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 deprecated

func Uint64Ptr(v uint64) *uint64

Uint64Ptr returns a pointer to a uint64.

Deprecated: Use Ptr instead.

func Unquote

func Unquote(s string) string

Unquote returns a string with the input string unquoted

func Value

func Value[T any](v *T) T

Value returns a value from a pointer, or a zero value if the pointer is nil

Types

This section is empty.

Jump to

Keyboard shortcuts

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