Documentation
¶
Index ¶
- func Choice[T any](arr []T) (T, bool)
- func DateRange(start, end time.Time) time.Time
- func FloatRange(min, max float64) float64
- func IntN(max int) int
- func IntRange(min, max int) int
- func Letters(n uint) string
- func LettersAndNumbers(n int) string
- func NewId() (int64, error)
- func NowRecent(dur time.Duration) time.Time
- func OneLiner() string
- func Paragraph(sentences, wordsPerSentence int) string
- func Sentence(words int) string
- func ShortID() string
- func Shuffle[T any](arr []T)
- type Article
- type Order
- type OrderItem
- type Person
- type Product
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FloatRange ¶ added in v0.0.29
FloatRange 生成 [min, max] 的浮点数
func LettersAndNumbers ¶ added in v0.0.29
LettersAndNumbers 生成指定长度的随机字符串(数字 + 大小写字母) 使用 crypto/rand 保证安全级随机。
func OneLiner ¶ added in v0.0.29
func OneLiner() string
OneLiner 返回一行短文案:优先用 Blurb/Comment 之类,长度可控(大致)
Types ¶
type Article ¶ added in v0.0.29
type Article struct {
Title string `json:"title,omitempty" yaml:"title"`
Author string `json:"author,omitempty" yaml:"author"`
Summary string `json:"summary,omitempty" yaml:"summary"`
Contents []string `json:"contents,omitempty" yaml:"contents"`
}
func NewArticle ¶
NewArticle 生成文章, 输入 段落数量,句子词数
type Order ¶ added in v0.0.29
type Order struct {
ID string `json:"id,omitempty" yaml:"id"`
User string `json:"user,omitempty" yaml:"user"`
Items []OrderItem `json:"items,omitempty" yaml:"items"`
Total float64 `json:"total,omitempty" yaml:"total"`
Currency string `json:"currency,omitempty" yaml:"currency"`
Status string `json:"status,omitempty" yaml:"status"` // created/paid/shipped/finished/refunded
CreatedAt time.Time `json:"created_at" yaml:"created_at"`
}
type Person ¶ added in v0.0.29
type Person struct {
Name string `json:"name,omitempty" yaml:"name"`
Email string `json:"email,omitempty" yaml:"email"`
Phone string `json:"phone,omitempty" yaml:"phone"`
Gender string `json:"gender,omitempty" yaml:"gender"`
Birthday string `json:"birthday,omitempty" yaml:"birthday"`
Address string `json:"address,omitempty" yaml:"address"`
}
type Product ¶ added in v0.0.29
type Product struct {
ID string `json:"id,omitempty" yaml:"id"`
Name string `json:"name,omitempty" yaml:"name"`
Category string `json:"category,omitempty" yaml:"category"`
Description string `json:"description,omitempty" yaml:"description"`
Price float64 `json:"price,omitempty" yaml:"price"`
Currency string `json:"currency,omitempty" yaml:"currency"`
Stock int `json:"stock,omitempty" yaml:"stock"`
CreatedAt time.Time `json:"created_at" yaml:"created_at"`
}
Click to show internal directories.
Click to hide internal directories.