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