Commit a21b473e authored by liuyuhang's avatar liuyuhang

Update linter_warning处理.md

parent 5f8c6a85
## 本地查看自己所修改模块golint warning的命令:
## 本地查看自己所修改模块golint warning的命令:
......@@ -6,6 +6,10 @@
> * go vet plugin/...
> * go vet plugin/dapp/...
## 本地查看自己所修改模块ineffassign warning的命令:
> * ineffassign plugin/...
> * go vet plugin/dapp/...
## golint warning修改方法:
### 1、导出结构体、变量、常量、函数需加注释
> * lint warning: exported const HashSize should have comment or be unexported
......@@ -128,4 +132,59 @@ func (ws *walletStore) GetFeeAmount(minFee int64) int64 {
if index < 0 {
return fmt.Errorf("Action %s Not Existed", this.ActionName)
}
```
\ No newline at end of file
```
## ineffassign warning修改方法:
### 1、导出结构体、变量、常量、函数需加注释
> * ineffectual assignment to ty
```
func (acc *DB) depositBalance(execaddr string, amount int64) (*types.Receipt, error) {
ty := int32(types.TyLogDeposit)
ty = types.TyLogDeposit
log1 := &types.ReceiptLog{
Ty: ty,
Log: types.Encode(receiptBalance),
}
kv := acc.GetKVSet(acc1)
return &types.Receipt{
Ty: types.ExecOk,
KV: kv,
Logs: []*types.ReceiptLog{log1},
}, nil
}
```
改为
```
func (acc *DB) depositBalance(execaddr string, amount int64) (*types.Receipt, error) {
ty := int32(types.TyLogDeposit)
ty = types.TyLogDeposit
log1 := &types.ReceiptLog{
Ty: int32(types.TyLogDeposit),
Log: types.Encode(receiptBalance),
}
kv := acc.GetKVSet(acc1)
return &types.Receipt{
Ty: types.ExecOk,
KV: kv,
Logs: []*types.ReceiptLog{log1},
}, nil
}
```
或者
```
ty := int32(types.TyLogDeposit)
_ = ty
ty = types.TyLogDeposit
log1 := &types.ReceiptLog{
Ty: ty,
Log: types.Encode(receiptBalance),
}
kv := acc.GetKVSet(acc1)
return &types.Receipt{
Ty: types.ExecOk,
KV: kv,
Logs: []*types.ReceiptLog{log1},
}, nil
}
```
推荐第一种
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment