package test import ( "github.com/360EntSecGroup-Skylar/excelize/v2" "hudongzhuanjia/models" "testing" "time" ) func TestAddSensitive(t *testing.T) { f, err := excelize.OpenFile("敏感词汇.xlsx") if err != nil { t.Fatal(err) } rows, err := f.GetRows("big_audit_keyword") for i, row := range rows { if i == 0 { continue } if err := models.Save(nil, &models.Sensitive{ Keyword: row[1], Category: row[2], Host: row[3], CreateAt: time.Now(), UpdateAt: time.Now(), }, nil); err != nil { t.Fatal(err) } } }