builtin

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(x, y any, ignores ...any) (bool, error)

func Diff

func Diff(x, y any, ignores ...any) (string, error)

func File added in v0.130.0

func File(root string) func(string) (any, error)

File returns a function that reads a file from the given root directory.

func Intersect

func Intersect(x, y any) any

func Merge

func Merge(x ...any) (any, error)

func Omit

func Omit(x any, keys ...string) (any, error)

func Pick

func Pick(x any, keys ...string) (any, error)

func Time

func Time(v any) (time.Time, error)

func Url

func Url(rawURL string) (*url.URL, error)

Types

type Faker

type Faker struct {
	// contains filtered or unexported fields
}

func NewFaker

func NewFaker() *Faker

func (*Faker) Bool

func (f *Faker) Bool() bool

func (*Faker) Color

func (f *Faker) Color() string

func (*Faker) Date

func (f *Faker) Date() time.Time

func (*Faker) Day

func (f *Faker) Day() int

func (*Faker) Digit

func (f *Faker) Digit() string

func (*Faker) DigitN

func (f *Faker) DigitN(n int) string

func (*Faker) Domain

func (f *Faker) Domain() string

func (*Faker) Email

func (f *Faker) Email() string

func (*Faker) Emoji

func (f *Faker) Emoji() string

func (*Faker) FirstName

func (f *Faker) FirstName() string

func (*Faker) Float

func (f *Faker) Float() float64

func (*Faker) FloatRange

func (f *Faker) FloatRange(min, max float64) float64

func (*Faker) HTTPMethod

func (f *Faker) HTTPMethod() string

func (*Faker) HTTPStatusCode

func (f *Faker) HTTPStatusCode() int

func (*Faker) HTTPVersion

func (f *Faker) HTTPVersion() string

func (*Faker) HexColor

func (f *Faker) HexColor() string

func (*Faker) Hour

func (f *Faker) Hour() int

func (*Faker) IPv4

func (f *Faker) IPv4() string

func (*Faker) IPv6

func (f *Faker) IPv6() string

func (*Faker) Int

func (f *Faker) Int() int

func (*Faker) IntRange

func (f *Faker) IntRange(min int, max int) int

func (*Faker) LastName

func (f *Faker) LastName() string

func (*Faker) Letter

func (f *Faker) Letter() string

func (*Faker) LetterN

func (f *Faker) LetterN(n int) string

func (*Faker) Lexify

func (f *Faker) Lexify(str string) string

func (*Faker) Minute

func (f *Faker) Minute() int

func (*Faker) Month

func (f *Faker) Month() int

func (*Faker) Name

func (f *Faker) Name() string

func (*Faker) NanoSecond

func (f *Faker) NanoSecond() int

func (*Faker) Numerify

func (f *Faker) Numerify(str string) string

func (*Faker) Password

func (f *Faker) Password(lower bool, upper bool, numeric bool, special bool, space bool, num int) string

func (*Faker) RandomInt

func (f *Faker) RandomInt(i []int) int

func (*Faker) RandomString

func (f *Faker) RandomString(a []string) string

func (*Faker) Regex added in v0.140.1

func (f *Faker) Regex(pattern string) (string, error)

Regex generates a random string that matches the given regex pattern.

func (*Faker) Second

func (f *Faker) Second() int

func (*Faker) ULID

func (f *Faker) ULID() (string, error)

ULID returns ULID.

func (*Faker) URL

func (f *Faker) URL() string

func (*Faker) UUID

func (f *Faker) UUID() string

func (*Faker) UUIDv4

func (f *Faker) UUIDv4() string

UUIDv4 returns UUID v4.

func (*Faker) UUIDv6

func (f *Faker) UUIDv6() string

UUIDv6 returns UUID v6.

func (*Faker) UUIDv7

func (f *Faker) UUIDv7() string

UUIDv7 returns UUID v7.

func (*Faker) UserAgent

func (f *Faker) UserAgent() string

func (*Faker) Username

func (f *Faker) Username() string

func (*Faker) Year

func (f *Faker) Year() int

type Hash added in v1.3.0

type Hash struct{}

Hash provides methods to compute hash values using various algorithms.

func NewHash added in v1.3.0

func NewHash() *Hash

NewHash creates a new Hash instance. NewHash is mapped to the built-in function `hash`.

func (*Hash) Sha256 added in v1.3.0

func (h *Hash) Sha256(v any) (string, error)

Sha256 computes SHA-256 hash of the input data and returns it as a hex string.

func (*Hash) Sha512 added in v1.3.0

func (h *Hash) Sha512(v any) (string, error)

Sha512 computes SHA-512 hash of the input data and returns it as a hex string.

type JWTOptions added in v0.137.0

type JWTOptions struct {
	Secret        string         `json:"secret"`         // Required
	Algorithm     string         `json:"algorithm"`      // Optional: HS256, HS384, HS512 (default: HS256)
	Subject       string         `json:"subject"`        // Optional: sub claim
	Audience      []string       `json:"audience"`       // Optional: aud claim
	Issuer        string         `json:"issuer"`         // Optional: iss claim
	ID            string         `json:"id"`             // Optional: jti claim
	ExpiresIn     string         `json:"expires_in"`     // Optional: duration like "1h", "30m"
	NotBefore     string         `json:"not_before"`     // Optional: duration like "5m"
	PrivateClaims map[string]any `json:"private_claims"` // Optional: private claims
}

JWTOptions represents options for JWT signing and parsing. It has a structure that allows defining Registered Claim Names, some Public Claim Names, and Private Claim Names. During actual signing and parsing, JSON data for the key names defined in the structure tag is specified.

type Jwt added in v0.137.0

type Jwt struct {
}

Jwt provides methods to sign and parse JSON Web Tokens (JWT).

func NewJwt added in v0.137.0

func NewJwt() *Jwt

NewJwt is mapped to the built-in function `jwt`.

func (*Jwt) Parse added in v0.137.0

func (j *Jwt) Parse(serialized string, opts map[string]any) (map[string]any, error)

Parse validates and parses a JWT string serialized with the specified options. If the signature is correctly validated and parsed, the payload map is returned.

func (*Jwt) Sign added in v0.137.0

func (j *Jwt) Sign(opts map[string]any) (string, error)

Sign generates a signed JWT string with the specified options. The options are accepted as an argument in the form of a map of JSON data defined by the struct tag of the JWTOptions structure.

Jump to

Keyboard shortcuts

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