update for golangci-lint

This commit is contained in:
wh_zcy 2022-09-07 18:24:55 +08:00
parent 051c2713c3
commit e3861971e7
12 changed files with 39 additions and 46 deletions

View File

@ -1,7 +1,25 @@
run:
skip-dirs:
- pb
- sys/configure/
tests: false
go: '1.18'
output:
# format: json
sort-results: true
linters: linters:
disable-all: true disable-all: true
enable: enable:
- typecheck - nilerr
- goimports - errcheck
- unused - gosimple
- errcheck - govet
- ineffassign
- staticcheck
- typecheck
- unused
# more linters https://golangci-lint.run/usage/linters/
linters-settings:
funlen:
statements: 60

View File

@ -36,7 +36,7 @@ func UnGz(tarFile, dest string) error {
if err != nil { if err != nil {
return err return err
} }
io.Copy(file, tr) _, _ = io.Copy(file, tr)
} }
return nil return nil
} }
@ -58,7 +58,9 @@ func UnGzip(tarName, xpath string) (err error) {
err = tarFile.Close() err = tarFile.Close()
}() }()
os.Mkdir(xpath, 0755) if err := os.Mkdir(xpath, 0755); err != nil {
return err
}
absPath, err := filepath.Abs(xpath) absPath, err := filepath.Abs(xpath)
if err != nil { if err != nil {

View File

@ -27,7 +27,9 @@ func Unzip(src string, dest string) ([]string, error) {
filenames = append(filenames, fpath) filenames = append(filenames, fpath)
if f.FileInfo().IsDir() { if f.FileInfo().IsDir() {
// Make Folder // Make Folder
os.MkdirAll(fpath, os.ModePerm) if err := os.MkdirAll(fpath, os.ModePerm); err != nil {
return nil, err
}
continue continue
} }
// Make File // Make File

View File

@ -81,7 +81,7 @@ func (this *DbServiceImpl) GetLubanConf(key string) *model.GenTool {
val := b.Get([]byte(key)) val := b.Get([]byte(key))
if err = json.Unmarshal(val, model); err != nil { if err = json.Unmarshal(val, model); err != nil {
logrus.Errorf("get gen conf err:%v", err) logrus.Errorf("get gen conf err:%v", err)
return nil return err
} }
return nil return nil
}); err != nil { }); err != nil {
@ -108,7 +108,7 @@ func (this *DbServiceImpl) GetSSHConf(key string) *model.SSHModel {
val := b.Get([]byte(key)) val := b.Get([]byte(key))
if err = json.Unmarshal(val, model); err != nil { if err = json.Unmarshal(val, model); err != nil {
logrus.Errorf("get gen conf err:%v", err) logrus.Errorf("get gen conf err:%v", err)
return nil return err
} }
return nil return nil
}); err != nil { }); err != nil {
@ -131,7 +131,7 @@ func (this *DbServiceImpl) GetPbConf() *model.PbConfModel {
val := b.Get([]byte(common.BUCKET_PBCONF)) val := b.Get([]byte(common.BUCKET_PBCONF))
if err = json.Unmarshal(val, model); err != nil { if err = json.Unmarshal(val, model); err != nil {
logrus.Errorf("get gen conf err:%v", err) logrus.Errorf("get gen conf err:%v", err)
return nil return err
} }
return nil return nil
}); err != nil { }); err != nil {

View File

@ -84,61 +84,42 @@ func writetoline(line *pools.Buffer, v interface{}) {
switch v := v.(type) { switch v := v.(type) {
case nil: case nil:
line.AppendString("nil") line.AppendString("nil")
break
case string: case string:
line.AppendString(v) line.AppendString(v)
break
case []byte: case []byte:
line.AppendBytes(v) line.AppendBytes(v)
break
case int: case int:
line.AppendInt(int64(v)) line.AppendInt(int64(v))
break
case int8: case int8:
line.AppendInt(int64(v)) line.AppendInt(int64(v))
break
case int16: case int16:
line.AppendInt(int64(v)) line.AppendInt(int64(v))
break
case int32: case int32:
line.AppendInt(int64(v)) line.AppendInt(int64(v))
break
case int64: case int64:
line.AppendInt(int64(v)) line.AppendInt(int64(v))
break
case uint: case uint:
line.AppendUint(uint64(v)) line.AppendUint(uint64(v))
break
case uint8: case uint8:
line.AppendUint(uint64(v)) line.AppendUint(uint64(v))
break
case uint16: case uint16:
line.AppendUint(uint64(v)) line.AppendUint(uint64(v))
break
case uint32: case uint32:
line.AppendUint(uint64(v)) line.AppendUint(uint64(v))
break
case uint64: case uint64:
line.AppendUint(uint64(v)) line.AppendUint(uint64(v))
break
case float32: case float32:
line.AppendFloat(float64(v), 64) line.AppendFloat(float64(v), 64)
break
case float64: case float64:
line.AppendFloat(v, 64) line.AppendFloat(v, 64)
break
case bool: case bool:
line.AppendBool(v) line.AppendBool(v)
break
case time.Time: case time.Time:
line.AppendTime(v, time.RFC3339Nano) line.AppendTime(v, time.RFC3339Nano)
break
case time.Duration: case time.Duration:
line.AppendInt(v.Nanoseconds()) line.AppendInt(v.Nanoseconds())
break
default: default:
d, _ := json.Marshal(v) d, _ := json.Marshal(v)
line.AppendBytes(d) line.AppendBytes(d)
break
} }
} }

View File

@ -137,7 +137,7 @@ Redis Lset 通过索引来设置元素的值。
*/ */
func (this *Redis) LSet(key string, index int, value interface{}) (err error) { func (this *Redis) LSet(key string, index int, value interface{}) (err error) {
var resultvalue []byte var resultvalue []byte
if resultvalue, err = this.codec.Marshal(value); err == nil { if resultvalue, err = this.codec.Marshal(value); err != nil {
return return
} }
err = this.client.Do(this.client.Context(), "LSET", key, index, resultvalue).Err() err = this.client.Do(this.client.Context(), "LSET", key, index, resultvalue).Err()

View File

@ -136,7 +136,7 @@ Redis Lset 通过索引来设置元素的值。
*/ */
func (this *RedisPipe) LSet(key string, index int, value interface{}) (err error) { func (this *RedisPipe) LSet(key string, index int, value interface{}) (err error) {
var resultvalue []byte var resultvalue []byte
if resultvalue, err = this.codec.Marshal(value); err == nil { if resultvalue, err = this.codec.Marshal(value); err != nil {
return return
} }
err = this.client.Do(this.ctx, "LSET", key, index, resultvalue).Err() err = this.client.Do(this.ctx, "LSET", key, index, resultvalue).Err()

View File

@ -137,7 +137,7 @@ Redis Lset 通过索引来设置元素的值。
*/ */
func (this *Redis) LSet(key string, index int, value interface{}) (err error) { func (this *Redis) LSet(key string, index int, value interface{}) (err error) {
var resultvalue []byte var resultvalue []byte
if resultvalue, err = this.codec.Marshal(value); err == nil { if resultvalue, err = this.codec.Marshal(value); err != nil {
return return
} }
err = this.client.Do(this.client.Context(), "LSET", key, index, resultvalue).Err() err = this.client.Do(this.client.Context(), "LSET", key, index, resultvalue).Err()

View File

@ -39,7 +39,7 @@ func init() {
//从字符串中读取float 对象 //从字符串中读取float 对象
func ReadBigFloatForString(buf []byte) (ret *big.Float, n int, err error) { func ReadBigFloatForString(buf []byte) (ret *big.Float, n int, err error) {
var str string var str string
if str, n, err = readNumberAsString(buf); err == nil { if str, n, err = readNumberAsString(buf); err != nil {
return return
} }
prec := 64 prec := 64

View File

@ -38,7 +38,7 @@ func (this *ModelRtaskRecord) verifyFromDb(uid string, cfg *cfg.GameRdtaskCondiD
func (this *ModelRtask) verfiyRtype1(uid string, cfg *cfg.GameRdtaskCondiData) (err error, ok bool) { func (this *ModelRtask) verfiyRtype1(uid string, cfg *cfg.GameRdtaskCondiData) (err error, ok bool) {
heroModule, err := this.service.GetModule(comm.ModuleHero) heroModule, err := this.service.GetModule(comm.ModuleHero)
if err != nil { if err != nil {
return nil, false return err, false
} }
if h, y := heroModule.(comm.IHero); y { if h, y := heroModule.(comm.IHero); y {

View File

@ -23,15 +23,7 @@ func (this *ModelExpand) Init(service core.IService, module core.IModule, comp c
return return
} }
//获取用户
func (this *ModelExpand) getUserSession(uid string) (cuser *pb.CacheUser) {
cuser = &pb.CacheUser{}
if err := this.Get(uid, cuser); err != nil {
this.module.Errorf("GetUserSession err:%v", err)
return
}
return
}
//获取用户通过扩展表 //获取用户通过扩展表
func (this *ModelExpand) GetUserExpand(uid string) (result *pb.DBUserExpand, err error) { func (this *ModelExpand) GetUserExpand(uid string) (result *pb.DBUserExpand, err error) {

View File

@ -80,8 +80,6 @@ func (this *ModelSetting) checkInitCount(uid string) bool {
return false return false
} }
ue.InitdataCount++ ue.InitdataCount++
} else {
} }
} }