go 常见问题
以下是我在go项目中碰到问题
1. 如何只测试指定的test文件,而不是所有的单元测试都跑一遍.
go tool vet -test -v src\github.com\astaxie\beego\controller_test.go
go tool vet 是个很不错的工具,里面有很强大的功能
go tool vet 参数
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | Usage of vet: vet [flags] directory... vet [flags] files... # Must be a single package For more information run godoc golang.org /x/tools/cmd/vet Flags: -all check everything; disabled if any explicit check is requested (default true ) -asmdecl check assembly against Go declarations (default unset ) -assign check for useless assignments (default unset ) -atomic check for common mistaken usages of the sync /atomic package (default unset ) -bool check for mistakes involving boolean operators (default unset ) -buildtags check that +build tags are valid (default unset ) -composites check that composite literals used field-keyed elements (default unset ) -compositewhitelist use composite white list; for testing only (default true ) -copylocks check that locks are not passed by value (default unset ) -methods check that canonically named methods are canonically defined (default unset ) -nilfunc check for comparisons between functions and nil (default unset ) - printf check printf -like invocations (default unset ) -printfuncs string comma-separated list of print function names to check -rangeloops check that range loop variables are used correctly (default unset ) -shadow check for shadowed variables (experimental; must be set explicitly) (default unset ) -shadowstrict whether to be strict about shadowing; can be noisy - shift check for useless shifts (default unset ) -structtags check that struct field tags have canonical format and apply to exported fields as needed (default unset ) -tags string comma-separated list of build tags to apply when parsing - test for testing only: sets -all and -shadow -unreachable check for unreachable code (default unset ) -unsafeptr check for misuse of unsafe.Pointer (default unset ) -unusedfuncs string comma-separated list of functions whose results must be used (default "errors.New,fmt.Errorf,fmt.Sprintf,fmt.Sprint,sort.Reverse" ) -unusedresult check for unused result of calls to functions in -unusedfuncs list and methods in -unusedstringmethods list (default unset ) -unusedstringmethods string comma-separated list of names of methods of type func() string whose results must be used (default "Error,String" ) - v verbose |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】凌霞软件回馈社区,携手博客园推出1Panel与Halo联合会员
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何统计不同电话号码的个数?—位图法
· C#高性能开发之类型系统:从 C# 7.0 到 C# 14 的类型系统演进全景
· 从零实现富文本编辑器#3-基于Delta的线性数据结构模型
· 记一次 .NET某旅行社酒店管理系统 卡死分析
· 长文讲解 MCP 和案例实战
· 基于Blazor实现的运输信息管理系统
· 微信支付功能的设计实现与关键实践(UniApp+Java)全代码
· 用c#从头写一个AI agent,实现企业内部自然语言数据统计分析
· 三维装箱问题(3D Bin Packing Problem, 3D-BPP)
· Windows 提权指南