update for golangci-lint
This commit is contained in:
parent
051c2713c3
commit
e3861971e7
@ -1,7 +1,25 @@
|
||||
run:
|
||||
skip-dirs:
|
||||
- pb
|
||||
- sys/configure/
|
||||
tests: false
|
||||
go: '1.18'
|
||||
output:
|
||||
# format: json
|
||||
sort-results: true
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- typecheck
|
||||
- goimports
|
||||
- unused
|
||||
- nilerr
|
||||
- errcheck
|
||||
- gosimple
|
||||
- govet
|
||||
- ineffassign
|
||||
- staticcheck
|
||||
- typecheck
|
||||
- unused
|
||||
# more linters https://golangci-lint.run/usage/linters/
|
||||
|
||||
linters-settings:
|
||||
funlen:
|
||||
statements: 60
|
@ -36,7 +36,7 @@ func UnGz(tarFile, dest string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
io.Copy(file, tr)
|
||||
_, _ = io.Copy(file, tr)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -58,7 +58,9 @@ func UnGzip(tarName, xpath string) (err error) {
|
||||
err = tarFile.Close()
|
||||
}()
|
||||
|
||||
os.Mkdir(xpath, 0755)
|
||||
if err := os.Mkdir(xpath, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
absPath, err := filepath.Abs(xpath)
|
||||
if err != nil {
|
||||
|
@ -27,7 +27,9 @@ func Unzip(src string, dest string) ([]string, error) {
|
||||
filenames = append(filenames, fpath)
|
||||
if f.FileInfo().IsDir() {
|
||||
// Make Folder
|
||||
os.MkdirAll(fpath, os.ModePerm)
|
||||
if err := os.MkdirAll(fpath, os.ModePerm); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
continue
|
||||
}
|
||||
// Make File
|
||||
|
@ -81,7 +81,7 @@ func (this *DbServiceImpl) GetLubanConf(key string) *model.GenTool {
|
||||
val := b.Get([]byte(key))
|
||||
if err = json.Unmarshal(val, model); err != nil {
|
||||
logrus.Errorf("get gen conf err:%v", err)
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
@ -108,7 +108,7 @@ func (this *DbServiceImpl) GetSSHConf(key string) *model.SSHModel {
|
||||
val := b.Get([]byte(key))
|
||||
if err = json.Unmarshal(val, model); err != nil {
|
||||
logrus.Errorf("get gen conf err:%v", err)
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
@ -131,7 +131,7 @@ func (this *DbServiceImpl) GetPbConf() *model.PbConfModel {
|
||||
val := b.Get([]byte(common.BUCKET_PBCONF))
|
||||
if err = json.Unmarshal(val, model); err != nil {
|
||||
logrus.Errorf("get gen conf err:%v", err)
|
||||
return nil
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}); err != nil {
|
||||
|
@ -84,61 +84,42 @@ func writetoline(line *pools.Buffer, v interface{}) {
|
||||
switch v := v.(type) {
|
||||
case nil:
|
||||
line.AppendString("nil")
|
||||
break
|
||||
case string:
|
||||
line.AppendString(v)
|
||||
break
|
||||
case []byte:
|
||||
line.AppendBytes(v)
|
||||
break
|
||||
case int:
|
||||
line.AppendInt(int64(v))
|
||||
break
|
||||
case int8:
|
||||
line.AppendInt(int64(v))
|
||||
break
|
||||
case int16:
|
||||
line.AppendInt(int64(v))
|
||||
break
|
||||
case int32:
|
||||
line.AppendInt(int64(v))
|
||||
break
|
||||
case int64:
|
||||
line.AppendInt(int64(v))
|
||||
break
|
||||
case uint:
|
||||
line.AppendUint(uint64(v))
|
||||
break
|
||||
case uint8:
|
||||
line.AppendUint(uint64(v))
|
||||
break
|
||||
case uint16:
|
||||
line.AppendUint(uint64(v))
|
||||
break
|
||||
case uint32:
|
||||
line.AppendUint(uint64(v))
|
||||
break
|
||||
case uint64:
|
||||
line.AppendUint(uint64(v))
|
||||
break
|
||||
case float32:
|
||||
line.AppendFloat(float64(v), 64)
|
||||
break
|
||||
case float64:
|
||||
line.AppendFloat(v, 64)
|
||||
break
|
||||
case bool:
|
||||
line.AppendBool(v)
|
||||
break
|
||||
case time.Time:
|
||||
line.AppendTime(v, time.RFC3339Nano)
|
||||
break
|
||||
case time.Duration:
|
||||
line.AppendInt(v.Nanoseconds())
|
||||
break
|
||||
default:
|
||||
d, _ := json.Marshal(v)
|
||||
line.AppendBytes(d)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ Redis Lset 通过索引来设置元素的值。
|
||||
*/
|
||||
func (this *Redis) LSet(key string, index int, value interface{}) (err error) {
|
||||
var resultvalue []byte
|
||||
if resultvalue, err = this.codec.Marshal(value); err == nil {
|
||||
if resultvalue, err = this.codec.Marshal(value); err != nil {
|
||||
return
|
||||
}
|
||||
err = this.client.Do(this.client.Context(), "LSET", key, index, resultvalue).Err()
|
||||
|
@ -136,7 +136,7 @@ Redis Lset 通过索引来设置元素的值。
|
||||
*/
|
||||
func (this *RedisPipe) LSet(key string, index int, value interface{}) (err error) {
|
||||
var resultvalue []byte
|
||||
if resultvalue, err = this.codec.Marshal(value); err == nil {
|
||||
if resultvalue, err = this.codec.Marshal(value); err != nil {
|
||||
return
|
||||
}
|
||||
err = this.client.Do(this.ctx, "LSET", key, index, resultvalue).Err()
|
||||
|
@ -137,7 +137,7 @@ Redis Lset 通过索引来设置元素的值。
|
||||
*/
|
||||
func (this *Redis) LSet(key string, index int, value interface{}) (err error) {
|
||||
var resultvalue []byte
|
||||
if resultvalue, err = this.codec.Marshal(value); err == nil {
|
||||
if resultvalue, err = this.codec.Marshal(value); err != nil {
|
||||
return
|
||||
}
|
||||
err = this.client.Do(this.client.Context(), "LSET", key, index, resultvalue).Err()
|
||||
|
@ -39,7 +39,7 @@ func init() {
|
||||
//从字符串中读取float 对象
|
||||
func ReadBigFloatForString(buf []byte) (ret *big.Float, n int, err error) {
|
||||
var str string
|
||||
if str, n, err = readNumberAsString(buf); err == nil {
|
||||
if str, n, err = readNumberAsString(buf); err != nil {
|
||||
return
|
||||
}
|
||||
prec := 64
|
||||
|
@ -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) {
|
||||
heroModule, err := this.service.GetModule(comm.ModuleHero)
|
||||
if err != nil {
|
||||
return nil, false
|
||||
return err, false
|
||||
}
|
||||
|
||||
if h, y := heroModule.(comm.IHero); y {
|
||||
|
@ -23,15 +23,7 @@ func (this *ModelExpand) Init(service core.IService, module core.IModule, comp c
|
||||
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) {
|
||||
|
@ -80,8 +80,6 @@ func (this *ModelSetting) checkInitCount(uid string) bool {
|
||||
return false
|
||||
}
|
||||
ue.InitdataCount++
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user