Usage of gotests: -all generate tests for all functions and methods -excl string regexp. generate tests for functions and methods that do not match. Takes precedence over -only, -exported, and -all -exported generate tests for exported functions and methods. Takes precedence over -only and -all -i print test inputs in error messages -nosubtests disable generating tests using the Go 1.7 subtests feature -only string regexp. generate tests for functions and methods that match only. Takes precedence over -all -parallel enable generating parallel subtests -template string optional. Specify custom test code templates, e.g. testify. This can also be set via environment variable GOTESTS_TEMPLATE -template_dir string optional. Path to a directory containing custom test code templates. Takes precedence over -template. This can also be set via environment variable GOTESTS_TEMPLATE_DIR -template_params string read external parameters to template by json with stdin -template_params_file string read external parameters to template by json with file -w write output to (test) files instead of stdout
Usage of godepgraph: -d (alias for -withgoroot) show dependencies of packages in the Go standard library -horizontal lay out the dependency graph horizontally instead of vertically -i string (alias for -ignorepackages) a comma-separated list of packages to ignore -ignorepackages string a comma-separated list of packages to ignore -ignoreprefixes string a comma-separated list of prefixes to ignore -l int (alias for -maxlevel) maximum level of the go dependency graph (default256) -maxlevel int max level of go dependency graph (default256) -nostdlib ignore packages in the Go standard library -novendor ignore packages in the vendor directory -o string (alias for -onlyprefixes) a comma-separated list of prefixes to include -onlyprefixes string a comma-separated list of prefixes to include -p string (alias for -ignoreprefixes) a comma-separated list of prefixes to ignore -s (alias for -nostdlib) ignore packages in the Go standard library -stoponerror stop on packageimport errors (defaulttrue) -t (alias for -withtests) include test packages -tags string a comma-separated list of build tags to consider satisfied during the build -withgoroot show dependencies of packages in the Go standard library -withtests include test packages
type A struct { Id int`gorm:"column:id;primary_key;AUTO_INCREMENT" json:"id"` Name string`gorm:"column:name" json:"name"` Book string`gorm:"column:book" json:"book"` CreateTime time.Time `gorm:"column:create_time;default:CURRENT_TIMESTAMP" json:"create_time"` }
Usage of depth: -explain string If set, show which packages import the specified target -internal If set, resolves dependencies of internal (stdlib) packages. -json If set, outputs the depencies in JSON format. -max int Sets the maximum depth of dependencies to resolve. -test If set, resolves dependencies used for testing.
go get -u gitlab.com/opennota/check/cmd/aligncheck go get -u gitlab.com/opennota/check/cmd/structcheck go get -u gitlab.com/opennota/check/cmd/varcheck
新版本Go用 go install gitlab.com/opennota/check/cmd/aligncheck@latest 安装
net/http: /usr/local/opt/go@1.14/libexec/src/net/http/h2_bundle.go:1507:6: struct http2Framer could have size 200 (currently 216) net/http: /usr/local/opt/go@1.14/libexec/src/net/http/h2_bundle.go:2274:6: struct http2HeadersFrameParam could have size 40 (currently 48) net/http: /usr/local/opt/go@1.14/libexec/src/net/http/h2_bundle.go:4058:6: struct http2serverConn could have size 368 (currently 384) net/http: /usr/local/opt/go@1.14/libexec/src/net/http/h2_bundle.go:4140:6: struct http2stream could have size 152 (currently 168) net/http: /usr/local/opt/go@1.14/libexec/src/net/http/h2_bundle.go:5851:6: struct http2requestBody could have size 32 (currently 40) net/http: /usr/local/opt/go@1.14/libexec/src/net/http/h2_bundle.go:6559:6: struct http2Transport could have size 80 (currently 88) net/http: /usr/local/opt/go@1.14/libexec/src/net/http/h2_bundle.go:6698:6: struct http2ClientConn could have size 368 (currently 384) net/http: /usr/local/opt/go@1.14/libexec/src/net/http/h2_bundle.go:6746:6: struct http2clientStream could have size 312 (currently 328) net/http: /usr/local/opt/go@1.14/libexec/src/net/http/h2_bundle.go:9252:6: struct http2writeData could have size 32 (currently 40) net/http: /usr/local/opt/go@1.14/libexec/src/net/http/h2_bundle.go:9335:6: struct http2writeResHeaders could have size 96 (currently 104) net/http: /usr/local/opt/go@1.14/libexec/src/net/http/h2_bundle.go:9407:6: struct http2writePushPromise could have size 48 (currently 56) net/http: /usr/local/opt/go@1.14/libexec/src/net/http/server.go:3294:6: struct timeoutWriter could have size 88 (currently 96) net/http: /usr/local/opt/go@1.14/libexec/src/net/http/server.go:418:6: struct response could have size 200 (currently 224) net/http: /usr/local/opt/go@1.14/libexec/src/net/http/server.go:653:6: struct connReader could have size 40 (currently 48) net/http: /usr/local/opt/go@1.14/libexec/src/net/http/transfer.go:59:6: struct transferWriter could have size 128 (currently 152) net/http: /usr/local/opt/go@1.14/libexec/src/net/http/transport.go:1103:6: struct wantConn could have size 168 (currently 176) net/http: /usr/local/opt/go@1.14/libexec/src/net/http/transport.go:1768:6: struct persistConn could have size 264 (currently 280) net/http: /usr/local/opt/go@1.14/libexec/src/net/http/transport.go:95:6: struct Transport could have size 288 (currently 304)
找到没有用到的结构体字段
structcheck --help
1 2 3 4 5 6
Usage of structcheck: -a Count assignments only -e Report exported fields -t Load test files too -tags string Build tags
Usage of eg: -beforeedit string A command to exec before each file is edited (e.g. chmod, checkout). Whitespace delimits argument words. The string'{}' is replaced by the file name. -help show detailed help message -t string template.go file specifying the refactoring -transitive apply refactoring to all dependencies too -v show verbose matcher diagnostics -w rewrite input files in place (by default, the results are printed to standard output)