Skip to content

Commit 9a90976

Browse files
author
Nexus
committed
fix: resolve errcheck lint issues
- Add _ = for unchecked error returns in cache_runtime_test.go - Add _ = for unchecked initValue calls in cache_runtime.go - Add _ = for unchecked WriteString in logger/xlog.go
1 parent 259d26f commit 9a90976

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

cache/runtime/cache_runtime.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func (ca *RuntimeCache) GetInt64(key string) (int64, error) {
9393
// Set cache to runtime.
9494
// ttl is second, if ttl is 0, it will be forever till restart.
9595
func (ca *RuntimeCache) Set(key string, value interface{}, ttl int64) error {
96-
ca.initValue(key, value, ttl)
96+
_ = ca.initValue(key, value, ttl)
9797
return nil
9898
}
9999

@@ -112,7 +112,7 @@ func (ca *RuntimeCache) Incr(key string) (int64, error) {
112112
itemObj, ok := ca.items.Load(key)
113113
if !ok {
114114
// if not exists, auto set new with 0
115-
ca.initValue(key, ZeroInt64, 0)
115+
_ = ca.initValue(key, ZeroInt64, 0)
116116
// reload
117117
itemObj, _ = ca.items.Load(key)
118118
}
@@ -147,7 +147,7 @@ func (ca *RuntimeCache) Decr(key string) (int64, error) {
147147
itemObj, ok := ca.items.Load(key)
148148
if !ok {
149149
// if not exists, auto set new with 0
150-
ca.initValue(key, ZeroInt64, 0)
150+
_ = ca.initValue(key, ZeroInt64, 0)
151151
// reload
152152
itemObj, _ = ca.items.Load(key)
153153
}

cache/runtime/cache_runtime_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func TestRuntimeCache_Delete(t *testing.T) {
101101
test.Nil(t, e)
102102
test.Equal(t, TESTCacheValue, value)
103103

104-
cache.Delete(TESTCacheKey)
104+
_, _ = cache.Delete(TESTCacheKey)
105105

106106
value, e = cache.Get(TESTCacheKey)
107107
test.Nil(t, e)
@@ -120,7 +120,7 @@ func TestRuntimeCache_ClearAll(t *testing.T) {
120120
}
121121
test.Equal(t, TESTCacheValue, val2)
122122

123-
cache.ClearAll()
123+
_, _ = cache.ClearAll()
124124
exists2, err := cache.Exists("2")
125125
if err != nil {
126126
t.Error(err)
@@ -137,15 +137,15 @@ func TestRuntimeCache_Incr(t *testing.T) {
137137

138138
go func(cache *RuntimeCache) {
139139
for i := 0; i < 50; i++ {
140-
cache.Incr(TESTCacheKey)
140+
_, _ = cache.Incr(TESTCacheKey)
141141
}
142142

143143
wg.Add(-1)
144144
}(cache)
145145

146146
go func(cache *RuntimeCache) {
147147
for i := 0; i < 50; i++ {
148-
cache.Incr(TESTCacheKey)
148+
_, _ = cache.Incr(TESTCacheKey)
149149
}
150150
wg.Add(-1)
151151
}(cache)

logger/xlog.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,5 +161,5 @@ func writeFile(logFile string, log string) {
161161
return
162162
}
163163
defer file.Close()
164-
file.WriteString(logstr)
164+
_, _ = file.WriteString(logstr)
165165
}

0 commit comments

Comments
 (0)