Documentation
¶
Index ¶
- Constants
- func MockData(x any, opts ...Option) error
- type MinMax
- type Option
- func WithContainsFieldSourceString(field string, source []string) Option
- func WithCountryEn() Option
- func WithIgnoreFields(fields ...string) Option
- func WithMax(max int64) Option
- func WithMaxLen(maxLen int) Option
- func WithMin(min int64) Option
- func WithMinLen(minLen int) Option
- func WithMinMaxLenByField(field string, minLen int, maxLen int) Option
- func WithTag(tag string) Option
- type Options
Constants ¶
View Source
const ( URL = "url" UserName = "username" NickName = "nickname" ID = "id" Time = "time" Email = "email" Country = "country" Ipv4 = "ipv4" // 省 Province = "province" // 市 City = "city" // 区 District = "district" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(*Options)
func WithContainsFieldSourceString ¶ added in v0.0.5
包含field字符串,就会使用source中的数据, 字段比较是string类型
func WithMinMaxLenByField ¶ added in v0.0.3
指定字段名,指定生成长度的范围, slice的长度和string的长度
type Options ¶
type Options struct { // 指定字段名,指定生成的数据来源 StringSource map[string][]string // 生成的mock数据的最大长度 MaxLen int // 生成的mock数据的最小长度 MinLen int // 生成的mock数据的最大值 Max int64 // 生成的mock数据的最小值 Min int64 // 指定字段名,生成最大长度 MinMaxLenByField map[string]MinMax // country 用中文还是英文 CountryChina bool // 默认是mock TagName string // 设置忽略的字段名 IgnoreFields map[string]bool // 省份 Province string // 城市 City string }
Click to show internal directories.
Click to hide internal directories.