tags在golang编译中的作用

golang没有条件编译,但是可以在编译的时候用tags参数来实现条件编译的效果。

这个参数的官方解释如下:

-tags 'tag list'
    a list of build tags to consider satisfied during the build.
    For more information about build tags, see the description of
    build constraints in the documentation for the go/build package.

等于没有说,说让去看 go/build package中的build constraints的描述,这又是在哪里?

在这里:go/build package文档

这个tags参数用法,可以参考这两篇文章,tags参数因为本身很简单,然后这两篇文章也写得好:
golang项目中使用条件编译
How to use conditional compilation with the go build tool

比较郁闷,在搜索引擎中搜索:golang tags,搜出来的基本上是tags在struct中的使用.

发表评论

邮箱地址不会被公开。 必填项已用*标注