当前位置: 首页 > 工具软件 > Staticcheck > 使用案例 >

golang 代码扫描 staticcheck

鲁明知
2023-12-01

staticcheck是一个go的静态代码扫描工具。

如果想递归扫描目录下的代码,执行如下操作

进入代码目录

staticcheck ./...

终端就会打印相应的代码提示信息:

httptransport/client/httpclient.go:40:39: should use make([]driver.UpdateOperation, len(ops)) instead (S1019)
httptransport/client/matcher.go:95:5: defers in this range loop won't run unless the channel gets closed (SA9001)
httptransport/updateoperationhandler_test.go:111:6: func testUpdateOperationDelete is unused (U1000)
initialize/services.go:250:26: cfg.Matcher.MaxConnPool is deprecated: Pool size should be set through the ConnString member. Currently, Clair only uses the "pgxpool" package to connect to the database, so see https://pkg.go.dev/github.com/jackc/pgx/v4/pgxpool#ParseConfig for more information.  (SA1019)
middleware/auth/httpauth_keyserver_test.go:165:7: should use time.Until instead of t.Sub(time.Now()) (S1024)
notifier/service/testmode.go:112:2: redundant return statement (S1023)

这是对clair的扫描结果。

下载地址:

Staticcheck

 类似资料: