公司网站建设专家京东网站内容建设
2026/4/17 13:24:09 网站建设 项目流程
公司网站建设专家,京东网站内容建设,最新新闻热点事件2022年,wordpress编辑器加按钮在 xxx.go 文件开头添加代码 //go:build debug ✅ 不加 //go:build debug 的文件 → 永远会被编译#xff08;默认行为#xff09; ✅ 加了 //go:build debug 的文件 → 「默认不编译」#xff0c;只有运行编译命令时手动加 -tags debug 才会编译 通俗解释 加了这个注释的文…在 xxx.go 文件开头添加代码//go:build debug✅ 不加 //go:build debug 的文件 → 永远会被编译默认行为✅ 加了 //go:build debug 的文件 → 「默认不编译」只有运行编译命令时手动加-tags debug才会编译通俗解释加了这个注释的文件默认是被忽略的生产打包go build/go run 完全不会包含它只有写命令go run -tags debug xxx.go或go build -tags debug xxx.go这个文件才会被编译进去反向用法//go:build !debug→ 意思是「只有不加 debug 标签编译时这个文件才生效」,注意有个!例如情况 1你的文件第一行写了 //go:build debug执行go run main.go→ 这个文件不参与编译被跳过执行go run -tags debug main.go→ 这个文件参与编译情况 2你的文件没写这个注释不管执行go run main.go还是go run -tags debug main.go→ 都会编译这个文件使用vscode系列编辑器时用到了 gopls 语言服务器默认会报下面的警告提示No packages found for open file D:\site\zero-core\search\tree_debug.go. This file may be excluded due to its build tags; try adding “-tags” to your gopls “buildFlags” configuration See the documentation for more information on working with build tags: https://github.com/golang/tools/blob/master/gopls/doc/settings.md#buildflags. go listsettings.json 配置中json第一层添加如下配置即可gopls:{buildFlags:[-tagsdebug]}

需要专业的网站建设服务?

联系我们获取免费的网站建设咨询和方案报价,让我们帮助您实现业务目标

立即咨询