tag 条件编译
最后更新于:2022-04-02 02:51:12
[TOC]
## 实例
### package 头写编译条件
cal/a_debug.go
```
// +build debug
package cal
func Echo() string {
return "debug"
}
```
cal/a_release.go
```
// +build !debug
package cal
func Echo() string {
return "release"
}
```
main.go
```
package main
import (
"demo/cal"
"fmt"
)
func main() {
fmt.Printf("%+v\n", cal.Echo())
}
```
编译 debug
```
go build -tags debug main.go
```
编译release
```
go build main.go
```
';