types

package
v1.6.21 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2026 License: Apache-2.0 Imports: 13 Imported by: 9 modules, 68 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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"
	ContentPathHeader       = "X-Path"
)
View Source
const (
	ContentTypeJSON       = "application/json"
	ContentTypeJSONStream = "application/ndjson"
	ContentTypeYAML       = "application/yaml"
	ContentTypeXML        = "application/xml"
	ContentTypeRSS        = "application/rss+xml"
	ContentTypeBinary     = "application/octet-stream"
	ContentTypeCSV        = "text/csv"
	ContentTypeTextXml    = "text/xml"
	ContentTypeTextPlain  = "text/plain"
	ContentTypeTextStream = "text/event-stream"
	ContentTypeForm       = "application/x-www-form-urlencoded"
	ContentTypeFormData   = "multipart/form-data"
	ContentTypeHTML       = "text/html"
	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 IsValidHeaderKey added in v1.6.10

func IsValidHeaderKey(s string) bool

IsValidHeaderKey reports whether s is a valid RFC 7230 header field name

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

type File added in v1.6.13

type File struct {
	Path        string
	Body        io.ReadCloser
	ContentType string               // optional MIME type
	Header      textproto.MIMEHeader // all part-level MIME headers
}

File represents a file part received from a multipart/form-data request, or to be sent as part of a multipart/form-data request. ContentType is optional; when set it is used as the part Content-Type instead of the default application/octet-stream. Header holds all part-level MIME headers (e.g. Content-Disposition, Content-Type, and any custom headers); it is populated when decoding and merged during encoding. Body must be closed by the caller after use to release any temporary storage allocated during request decoding.

Jump to

Keyboard shortcuts

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