Skip to content

Commit 984fd43

Browse files
committed
fix golint warning
1 parent ebfb011 commit 984fd43

22 files changed

+107
-97
lines changed

blockchain/proc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func (chain *BlockChain) ProcRecvMsg() {
1919
defer chain.recvwg.Done()
2020
reqnum := make(chan struct{}, 1000)
2121
for msg := range chain.client.Recv() {
22-
chainlog.Debug("blockchain recv", "msg", types.GetEventName(int(msg.Ty)), "id", msg.Id, "cap", len(reqnum))
22+
chainlog.Debug("blockchain recv", "msg", types.GetEventName(int(msg.Ty)), "id", msg.ID, "cap", len(reqnum))
2323
msgtype := msg.Ty
2424
reqnum <- struct{}{}
2525
atomic.AddInt32(&chain.runcount, 1)

cmd/tools/strategy/create_plugin_file_template.go

+15-15
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ package strategy
99
//const
1010
const (
1111
// 創建main.go的文件模板
12-
CPFT_MAIN_GO = `package main
12+
CPFTMAINGO = `package main
1313
1414
import (
1515
_ "github.com/33cn/chain33/system"
@@ -26,7 +26,7 @@ func main() {
2626
`
2727

2828
// 生成的配置文件模板 xxx.toml
29-
CPFT_CFG_TOML = `
29+
CPFTCFGTOML = `
3030
Title="${PROJECTNAME}"
3131
FixTime=false
3232
@@ -102,14 +102,14 @@ enableMVCC=false
102102
saveTokenTxList=false
103103
`
104104

105-
CPFT_RUNMAIN_BLOCK = `package main
105+
CPFTRUNMAINBLOCK = `package main
106106
107107
var ${PROJECTNAME} = `
108108

109109
// 生成项目运行主程序的模板 xxx.go
110110
// 顶部还需要加上package main
111111
//var bityuan = `CPFT_RUNMAIN`
112-
CPFT_RUNMAIN = `TestNet=false
112+
CPFTRUNMAIN = `TestNet=false
113113
[blockchain]
114114
defCacheSize=128
115115
maxFetchBlockNum=128
@@ -248,7 +248,7 @@ ForkTradeAsset= -1
248248
`
249249

250250
// 生成项目Makefile文件的模板 Makefile
251-
CPFT_MAKEFILE = `
251+
CPFTMAKEFILE = `
252252
CHAIN33=github.com/33cn/chain33
253253
CHAIN33_PATH=vendor/${CHAIN33}
254254
all: vendor proto build
@@ -297,7 +297,7 @@ clean:
297297
`
298298

299299
// 生成 .travis.yml 文件模板
300-
CPFT_TRAVIS_YML = `
300+
CPFTTRAVISYML = `
301301
language: go
302302
303303
go:
@@ -306,7 +306,7 @@ go:
306306
`
307307

308308
// 生成 plugin/plugin.toml的文件模板
309-
CPFT_PLUGIN_TOML = `
309+
CPFTPLUGINTOML = `
310310
# type字段仅支持 consensus dapp store
311311
[dapp-ticket]
312312
gitrepo = "github.com/33cn/plugin/plugin/dapp/ticket"
@@ -327,7 +327,7 @@ gitrepo = "github.com/33cn/plugin/plugin/dapp/token"
327327
gitrepo = "github.com/33cn/plugin/plugin/dapp/trade"
328328
`
329329
// 项目 cli/main.go 文件模板
330-
CPFT_CLI_MAIN = `package main
330+
CPFTCLIMAIN = `package main
331331
332332
import (
333333
_ "${PROJECTPATH}/plugin"
@@ -340,7 +340,7 @@ func main() {
340340
}
341341
`
342342
// plugin/dapp/xxxx/commands/cmd.go文件的模板c
343-
CPFT_DAPP_COMMANDS = `package commands
343+
CPFTDAPPCOMMANDS = `package commands
344344
345345
import (
346346
"github.com/spf13/cobra"
@@ -351,7 +351,7 @@ func Cmd() *cobra.Command {
351351
}`
352352

353353
// plugin/dapp/xxxx/plugin.go文件的模板
354-
CPFT_DAPP_PLUGIN = `package ${PROJECTNAME}
354+
CPFTDAPPPLUGIN = `package ${PROJECTNAME}
355355
356356
import (
357357
"github.com/33cn/chain33/pluginmgr"
@@ -372,7 +372,7 @@ func init() {
372372
`
373373

374374
// plugin/dapp/xxxx/executor/xxxx.go文件模板
375-
CPFT_DAPP_EXEC = `package executor
375+
CPFTDAPPEXEC = `package executor
376376
377377
import (
378378
log "github.com/inconshreveable/log15"
@@ -425,17 +425,17 @@ func (this *${CLASSNAME}) CheckTx(tx *types.Transaction, index int) error {
425425
}
426426
`
427427
// plugin/dapp/xxxx/proto/create_protobuf.sh文件模板
428-
CPFT_DAPP_CREATEPB = `#!/bin/sh
428+
CPFTDAPPCREATEPB = `#!/bin/sh
429429
protoc --go_out=plugins=grpc:../types ./*.proto --proto_path=.
430430
`
431431

432432
// plugin/dapp/xxxx/proto/Makefile 文件模板
433-
CPFT_DAPP_MAKEFILE = `all:
433+
CPFTDAPPMAKEFILE = `all:
434434
sh ./create_protobuf.sh
435435
`
436436

437437
// plugin/dapp/xxxx/proto/xxxx.proto的文件模板
438-
CPFT_DAPP_PROTO = `syntax = "proto3";
438+
CPFTDAPPPROTO = `syntax = "proto3";
439439
package types;
440440
441441
message ${ACTIONNAME} {
@@ -450,7 +450,7 @@ message ${ACTIONNAME}None {
450450
`
451451

452452
// plugin/dapp/xxxx/types/types.go的文件模板cd
453-
CPFT_DAPP_TYPEFILE = `package types
453+
CPFTDAPPTYPEFILE = `package types
454454
455455
import (
456456
"gitlab.33.cn/chain33/chain33/types"

cmd/tools/strategy/createplugin.go

+15-15
Original file line numberDiff line numberDiff line change
@@ -78,31 +78,31 @@ func (c *createPluginStrategy) buildTask() []tasks.Task {
7878
taskSlice := make([]tasks.Task, 0)
7979
taskSlice = append(taskSlice,
8080
&tasks.CreateFileFromStrTemplateTask{
81-
SourceStr: CPFT_MAIN_GO,
81+
SourceStr: CPFTMAINGO,
8282
OutputFile: fmt.Sprintf("%s/main.go", c.projectPath),
8383
ReplaceKeyPairs: map[string]string{
8484
types.TagProjectName: c.projName,
8585
types.TagProjectPath: goprojpath,
8686
},
8787
},
8888
&tasks.CreateFileFromStrTemplateTask{
89-
SourceStr: CPFT_CFG_TOML,
89+
SourceStr: CPFTCFGTOML,
9090
OutputFile: fmt.Sprintf("%s/%s.toml", c.projectPath, c.projName),
9191
ReplaceKeyPairs: map[string]string{
9292
types.TagProjectName: c.projName,
9393
},
9494
},
9595
&tasks.CreateFileFromStrTemplateTask{
96-
SourceStr: CPFT_RUNMAIN,
97-
BlockStrBegin: CPFT_RUNMAIN_BLOCK + "`",
96+
SourceStr: CPFTRUNMAIN,
97+
BlockStrBegin: CPFTRUNMAINBLOCK + "`",
9898
BlockStrEnd: "`",
9999
OutputFile: fmt.Sprintf("%s/%s.go", c.projectPath, c.projName),
100100
ReplaceKeyPairs: map[string]string{
101101
types.TagProjectName: c.projName,
102102
},
103103
},
104104
&tasks.CreateFileFromStrTemplateTask{
105-
SourceStr: CPFT_MAKEFILE,
105+
SourceStr: CPFTMAKEFILE,
106106
OutputFile: fmt.Sprintf("%s/Makefile", c.projectPath),
107107
ReplaceKeyPairs: map[string]string{
108108
types.TagProjectName: c.projName,
@@ -112,36 +112,36 @@ func (c *createPluginStrategy) buildTask() []tasks.Task {
112112
},
113113
},
114114
&tasks.CreateFileFromStrTemplateTask{
115-
SourceStr: CPFT_TRAVIS_YML,
115+
SourceStr: CPFTTRAVISYML,
116116
OutputFile: fmt.Sprintf("%s/.travis.yml", c.projectPath),
117117
ReplaceKeyPairs: map[string]string{
118118
types.TagProjectName: c.projName,
119119
},
120120
},
121121
&tasks.CreateFileFromStrTemplateTask{
122-
SourceStr: CPFT_PLUGIN_TOML,
122+
SourceStr: CPFTPLUGINTOML,
123123
OutputFile: fmt.Sprintf("%s/plugin/plugin.toml", c.projectPath),
124124
ReplaceKeyPairs: map[string]string{
125125
types.TagProjectName: c.projName,
126126
},
127127
},
128128
&tasks.CreateFileFromStrTemplateTask{
129-
SourceStr: CPFT_CLI_MAIN,
129+
SourceStr: CPFTCLIMAIN,
130130
OutputFile: fmt.Sprintf("%s/cli/main.go", c.projectPath),
131131
ReplaceKeyPairs: map[string]string{
132132
types.TagProjectName: c.projName,
133133
types.TagProjectPath: goprojpath,
134134
},
135135
},
136136
&tasks.CreateFileFromStrTemplateTask{
137-
SourceStr: CPFT_DAPP_COMMANDS,
137+
SourceStr: CPFTDAPPCOMMANDS,
138138
OutputFile: fmt.Sprintf("%s/plugin/dapp/%s/commands/cmd.go", c.projectPath, c.execName),
139139
ReplaceKeyPairs: map[string]string{
140140
types.TagProjectName: c.projName,
141141
},
142142
},
143143
&tasks.CreateFileFromStrTemplateTask{
144-
SourceStr: CPFT_DAPP_PLUGIN,
144+
SourceStr: CPFTDAPPPLUGIN,
145145
OutputFile: fmt.Sprintf("%s/plugin/dapp/%s/plugin.go", c.projectPath, c.projName),
146146
ReplaceKeyPairs: map[string]string{
147147
types.TagProjectName: c.projName,
@@ -150,7 +150,7 @@ func (c *createPluginStrategy) buildTask() []tasks.Task {
150150
},
151151
},
152152
&tasks.CreateFileFromStrTemplateTask{
153-
SourceStr: CPFT_DAPP_EXEC,
153+
SourceStr: CPFTDAPPEXEC,
154154
OutputFile: fmt.Sprintf("%s/plugin/dapp/%s/executor/%s.go", c.projectPath, c.projName, c.execName),
155155
ReplaceKeyPairs: map[string]string{
156156
types.TagProjectName: c.projName,
@@ -159,24 +159,24 @@ func (c *createPluginStrategy) buildTask() []tasks.Task {
159159
},
160160
},
161161
&tasks.CreateFileFromStrTemplateTask{
162-
SourceStr: CPFT_DAPP_CREATEPB,
162+
SourceStr: CPFTDAPPCREATEPB,
163163
OutputFile: fmt.Sprintf("%s/plugin/dapp/%s/proto/create_protobuf.sh", c.projectPath, c.projName),
164164
ReplaceKeyPairs: map[string]string{},
165165
},
166166
&tasks.CreateFileFromStrTemplateTask{
167-
SourceStr: CPFT_DAPP_MAKEFILE,
167+
SourceStr: CPFTDAPPMAKEFILE,
168168
OutputFile: fmt.Sprintf("%s/plugin/dapp/%s/proto/Makefile", c.projectPath, c.projName),
169169
ReplaceKeyPairs: map[string]string{},
170170
},
171171
&tasks.CreateFileFromStrTemplateTask{
172-
SourceStr: CPFT_DAPP_PROTO,
172+
SourceStr: CPFTDAPPPROTO,
173173
OutputFile: fmt.Sprintf("%s/plugin/dapp/%s/proto/%s.proto", c.projectPath, c.projName, c.execName),
174174
ReplaceKeyPairs: map[string]string{
175175
types.TagActionName: c.classActionName,
176176
},
177177
},
178178
&tasks.CreateFileFromStrTemplateTask{
179-
SourceStr: CPFT_DAPP_TYPEFILE,
179+
SourceStr: CPFTDAPPTYPEFILE,
180180
OutputFile: fmt.Sprintf("%s/plugin/dapp/%s/types/types.go", c.projectPath, c.projName),
181181
ReplaceKeyPairs: map[string]string{
182182
types.TagExecNameFB: c.execNameFB,

cmd/tools/types/types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const (
2121
KeyUpdateInit = "update_init"
2222
KeyCreatePlugin = "create_plugin"
2323

24-
DEF_CPM_CONFIGFILE = "chain33.cpm.toml"
24+
DEFCPMCONFIGFILE = "chain33.cpm.toml"
2525

2626
TagGoPath = "${GOPATH}"
2727
TagProjectName = "${PROJECTNAME}" // 项目名称替换标签

doc.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ chain33 是由复杂美科技有限公司开发的区块链链框架
1111
1212
3. 创新的 合约 调用和组合方式
1313
*/
14+
1415
package chain33
1516

1617
//有些包国内需要翻墙才能下载,我们把部分参见的包含在这里
1718
import (
18-
_ "golang.org/x/crypto/nacl/box"
19+
_ "golang.org/x/crypto/nacl/box" //register box package
1920
_ "golang.org/x/crypto/nacl/secretbox"
2021
_ "golang.org/x/crypto/ssh"
2122
)

golinter.sh

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ function filterLinter() {
1616
--enable=structcheck \
1717
--enable=goimports \
1818
--enable=misspell \
19+
--enable=golint \
1920
--vendor ./...)
2021
# --enable=staticcheck \
2122
# --enable=gocyclo \

mempool/mempool.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ func (mem *Mempool) SetQueueClient(client queue.Client) {
600600
defer mlog.Info("mempool message recv quit")
601601
defer mem.wg.Done()
602602
for msg := range mem.client.Recv() {
603-
mlog.Debug("mempool recv", "msgid", msg.Id, "msg", types.GetEventName(int(msg.Ty)))
603+
mlog.Debug("mempool recv", "msgid", msg.ID, "msg", types.GetEventName(int(msg.Ty)))
604604
beg := types.Now()
605605
switch msg.Ty {
606606
case types.EventTx:

mempool/pipeline_test.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,31 @@ import (
1616
func TestStep(t *testing.T) {
1717
done := make(chan struct{})
1818
in := make(chan queue.Message)
19-
msg := queue.Message{Id: 0}
19+
msg := queue.Message{ID: 0}
2020
cb := func(in queue.Message) queue.Message {
21-
in.Id++
21+
in.ID++
2222
time.Sleep(time.Microsecond)
2323
return in
2424
}
2525
out := step(done, in, cb)
2626
in <- msg
2727
msg2 := <-out
28-
assert.Equal(t, msg2.Id, int64(1))
28+
assert.Equal(t, msg2.ID, int64(1))
2929
close(done)
3030
}
3131

3232
func TestMutiStep(t *testing.T) {
3333
done := make(chan struct{})
3434
in := make(chan queue.Message)
35-
msg := queue.Message{Id: 0}
35+
msg := queue.Message{ID: 0}
3636
step1 := func(in queue.Message) queue.Message {
37-
in.Id++
37+
in.ID++
3838
time.Sleep(time.Microsecond)
3939
return in
4040
}
4141
out1 := step(done, in, step1)
4242
step2 := func(in queue.Message) queue.Message {
43-
in.Id++
43+
in.ID++
4444
time.Sleep(time.Microsecond)
4545
return in
4646
}
@@ -50,16 +50,16 @@ func TestMutiStep(t *testing.T) {
5050
out3 := mergeList(done, out21, out22)
5151
in <- msg
5252
msg2 := <-out3
53-
assert.Equal(t, msg2.Id, int64(2))
53+
assert.Equal(t, msg2.ID, int64(2))
5454
close(done)
5555
}
5656

5757
func BenchmarkStep(b *testing.B) {
5858
done := make(chan struct{})
5959
in := make(chan queue.Message)
60-
msg := queue.Message{Id: 0}
60+
msg := queue.Message{ID: 0}
6161
cb := func(in queue.Message) queue.Message {
62-
in.Id++
62+
in.ID++
6363
time.Sleep(100 * time.Microsecond)
6464
return in
6565
}
@@ -71,17 +71,17 @@ func BenchmarkStep(b *testing.B) {
7171
}()
7272
for i := 0; i < b.N; i++ {
7373
msg2 := <-out
74-
assert.Equal(b, msg2.Id, int64(1))
74+
assert.Equal(b, msg2.ID, int64(1))
7575
}
7676
close(done)
7777
}
7878

7979
func BenchmarkStepMerge(b *testing.B) {
8080
done := make(chan struct{})
8181
in := make(chan queue.Message)
82-
msg := queue.Message{Id: 0}
82+
msg := queue.Message{ID: 0}
8383
cb := func(in queue.Message) queue.Message {
84-
in.Id++
84+
in.ID++
8585
time.Sleep(100 * time.Microsecond)
8686
return in
8787
}
@@ -97,7 +97,7 @@ func BenchmarkStepMerge(b *testing.B) {
9797
}()
9898
for i := 0; i < b.N; i++ {
9999
msg2 := <-out
100-
assert.Equal(b, msg2.Id, int64(1))
100+
assert.Equal(b, msg2.ID, int64(1))
101101
}
102102
close(done)
103103
}

0 commit comments

Comments
 (0)