GoLand编译带有构建标签的程序思路详解
作者:道道法 时间:2024-02-18 02:13:52
简单构建一个项目,如下是mian.go文件
package main
// 条件编译-构建标签-如何使用IDE编译和识别
func main() {
RequestByRpc()
}
模拟带有一个http tags的文件
// +build http
package main
import "fmt"
func RequestByHttp() {
fmt.Println("using http method")
}
模拟带有一个rpc tags的文件
// +build rpc
package main
import "fmt"
func RequestByRpc() {
fmt.Println("using rpc method")
}
在 Build Tags 中指定编译的标签,指定了这个之后,编译器可以正常识别带有指定标签的源码文件。但直接执行的话,还是会报错:undefined ***
剩下的还需要编辑 Go Build Configuration 文件,在配置文件中的 Go tool arguments 中指定 tags 参数,需要格外注意的是,tags 参数如果指定多个的话,是使用逗号进行分割的。
来源:https://blog.csdn.net/whynottrythis/article/details/108935012
标签:GoLand,编译,程序
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python 同级目录(兄弟目录)调用方式
2021-12-07 15:52:12
![](https://img.aspxhome.com/file/2023/8/134788_0s.png)
对json字符串与python字符串的不同之处详解
2023-11-22 04:35:39
关闭窗口时保存数据的办法
2009-02-19 13:39:00
如何用Python和JS实现的Web SSH工具
2021-04-23 13:50:13
![](https://img.aspxhome.com/file/2023/0/127670_0s.png)
python 判断是否为正小数和正整数的实例
2022-06-12 01:26:04
python中not not x 与bool(x) 的区别
2021-04-27 03:50:17
![](https://img.aspxhome.com/file/2023/1/120371_0s.png)
CKEditor/FCKEditor 使用 CKeditor 3.0.1 快速使用教程(含插入图片)
2022-10-16 14:04:14
nodejs简单实现TCP服务器端和客户端的聊天功能示例
2024-05-03 15:55:56
Python lambda 匿名函数优点和局限性深度总结
2023-07-25 19:22:00
django开发post接口简单案例,获取参数值的方法
2022-10-20 06:45:00
![](https://img.aspxhome.com/file/2023/6/109386_0s.jpg)
Python3中PyQt5简单实现文件打开及保存
2023-10-17 21:45:52
![](https://img.aspxhome.com/file/2023/4/63264_0s.png)
SQL脚本语言学习(黑客篇)
2008-02-29 13:09:00
使用python在本地电脑上快速处理数据
2022-07-30 14:43:11
pandas之分组groupby()的使用整理与总结
2022-04-23 17:24:42
![](https://img.aspxhome.com/file/2023/3/108033_0s.png)
Python函数式编程
2023-12-29 10:58:46
如何通俗的解释TypeScript 泛型
2024-04-10 16:18:31
mysql 单机数据库优化的一些实践
2024-01-15 19:01:25
![](https://img.aspxhome.com/file/2023/4/69834_0s.png)
用SQL统计SQLServe表存储空间大小的代码
2012-06-06 19:52:22
python将秒数转化为时间格式的实例
2023-09-24 12:10:22
Virtualenv 搭建 Py项目运行环境的教程详解
2023-02-22 04:56:33
![](https://img.aspxhome.com/file/2023/5/62625_0s.gif)