Golang中是否存在用于调试的宏之类的东西

Does there exists something like Macros in Golang for debugging

golang中有没有类似C/C++的宏,让开发者在debug阶段可以打印一些额外的debug信息?而在正式版中,只是将这些宏设置为false,这样它们就不会被编译,也不会打印额外的信息。这是一个片段来说明我的意思。

func demo() {
    // ...
    // the following line will not be compiled in release only in debug phase
    
    printMyDebugInfo(variable)
    
    // ...
}

最接近的大概是在两个版本中定义一个调试打印函数。

一个用于调试模式:

//go:build debug

package whatever

func debugPrint(in string) {
    print(in)
}

一个用于生产:

//go:build !debug

package whatever

func debugPrint(in string) {}

然后当你想使用调试版本时使用go build -tags debug