diff --git a/src/pkg/immutabletag/dao/immutable.go b/src/pkg/immutabletag/dao/immutable.go index 7450c5514..e7e338348 100644 --- a/src/pkg/immutabletag/dao/immutable.go +++ b/src/pkg/immutabletag/dao/immutable.go @@ -65,7 +65,7 @@ func (i *immutableRuleDao) GetImmutableRule(id int64) (*model.ImmutableRule, err func (i *immutableRuleDao) QueryImmutableRuleByProjectID(projectID int64) ([]model.ImmutableRule, error) { o := dao.GetOrmer() qs := o.QueryTable(&model.ImmutableRule{}).Filter("ProjectID", projectID) - var r []model.ImmutableRule + r := make([]model.ImmutableRule, 0) _, err := qs.All(&r) if err != nil { return nil, fmt.Errorf("failed to get immutable tag rule by projectID %d, error: %v", projectID, err) diff --git a/src/pkg/immutabletag/manager.go b/src/pkg/immutabletag/manager.go index b78911c9f..167e00726 100644 --- a/src/pkg/immutabletag/manager.go +++ b/src/pkg/immutabletag/manager.go @@ -79,7 +79,7 @@ func (drm *defaultRuleManager) QueryImmutableRuleByProjectID(projectID int64) ([ if err != nil { return nil, err } - var rules []model.Metadata + rules := make([]model.Metadata, 0) for _, daoRule := range daoRules { rule := model.Metadata{} if err = json.Unmarshal([]byte(daoRule.TagFilter), &rule); err != nil {