package product import "time" type Option struct { ID uint `gorm:"primary_key" json:"id"` Interval time.Duration `yaml:"interval"` ExchangeRate float64 `yaml:"exchangeRate"` //汇率 Freight float64 `yaml:"freight"` //运费 } func (c *Controller) LoadOption() { c.db.FirstOrCreate(&c.Option, Option{Interval: time.Hour * 30, ExchangeRate: 7.3, Freight: 100}) }