diff --git a/pkg/util/assert.go b/pkg/util/assert.go index e09c249a6..cd1f09d14 100644 --- a/pkg/util/assert.go +++ b/pkg/util/assert.go @@ -56,7 +56,7 @@ func IsNil(value interface{}) bool { // IsTrue returns whether the value is true. func IsTrue(value bool) bool { - return value == true + return value } // IsPositive returns whether the value is a positive number. diff --git a/supernode/daemon/mgr/cdn/cdn_gc.go b/supernode/daemon/mgr/cdn/cdn_gc.go index 4b4364478..2519bc1d1 100644 --- a/supernode/daemon/mgr/cdn/cdn_gc.go +++ b/supernode/daemon/mgr/cdn/cdn_gc.go @@ -58,7 +58,7 @@ func (cm *Manager) GetGCTaskIDs(ctx context.Context, taskMgr mgr.TaskMgr) ([]str // walkTaskIDs is used to avoid processing multiple times for the same taskID // which is extracted from file name. - walkTaskIDs := make(map[string]bool, 0) + walkTaskIDs := make(map[string]bool) walkFn := func(path string, info os.FileInfo, err error) error { logrus.Debugf("start to walk path(%s)", path) @@ -155,17 +155,13 @@ func getGCTasks(gapTasks, intervalTasks *treemap.Map) []string { for _, v := range gapTasks.Values() { if taskIDs, ok := v.([]string); ok { - for _, taskID := range taskIDs { - gcTasks = append(gcTasks, taskID) - } + gcTasks = append(gcTasks, taskIDs...) } } for _, v := range intervalTasks.Values() { if taskIDs, ok := v.([]string); ok { - for _, taskID := range taskIDs { - gcTasks = append(gcTasks, taskID) - } + gcTasks = append(gcTasks, taskIDs...) } } diff --git a/supernode/daemon/mgr/cdn/manager.go b/supernode/daemon/mgr/cdn/manager.go index 2aefcdb73..4a958b78a 100644 --- a/supernode/daemon/mgr/cdn/manager.go +++ b/supernode/daemon/mgr/cdn/manager.go @@ -158,7 +158,7 @@ func (cm *Manager) TriggerCDN(ctx context.Context, task *types.TaskInfo) (*types realMD5 := reader.Md5() success, err := cm.handleCDNResult(ctx, task, realMD5, httpFileLength, downloadMetadata.realHTTPFileLength, downloadMetadata.realFileLength) - if err != nil || success == false { + if err != nil || !success { return getUpdateTaskInfoWithStatusOnly(types.TaskInfoCdnStatusFAILED), err } diff --git a/supernode/daemon/mgr/cdn/reporter.go b/supernode/daemon/mgr/cdn/reporter.go index 929cd6376..efc927f84 100644 --- a/supernode/daemon/mgr/cdn/reporter.go +++ b/supernode/daemon/mgr/cdn/reporter.go @@ -58,7 +58,7 @@ func (re *reporter) reportCache(ctx context.Context, taskID string, metaData *fi } success, updateTaskInfo, err := re.processCacheByQuick(ctx, taskID, metaData, breakNum) - if err == nil && success == true { + if err == nil && success { // it is possible to succeed only if breakNum equals -1 return nil, updateTaskInfo, nil }