| 12345678910111213141516171819202122232425 |
- // Package factories 存放 category 工厂方法
- package factories
- import (
- "github.com/bxcodec/faker/v4"
- "github.com/runningwater/gohub/app/models/category"
- )
- func MakeCategories(times int) []category.Category {
- var objs []category.Category
- // 设置唯一值, 如 Category 模型中的某个字段需要唯一
- faker.SetGenerateUniqueValues(true)
- for range times {
- model := category.Category{
- Name: faker.Username(),
- Description: faker.Sentence(),
- }
- objs = append(objs, model)
- }
- return objs
- }
|