英文:
Golang build tags on multiple lines with go version 1.14
问题
我正在测试套件中使用多个Golang构建标签。
在Go 1.14中,有没有办法将它们拆分成多行?
例如,我想将这一行拆分成多行:
// +build integration integration_auth_pwd integration_auth_tls integration_config integration_groups integration_groups_mongodb integration_groups_sql integration_groups_cassandra
我尝试将它们拆分成这样:
// +build integration integration_auth_pwd integration_auth_tls \
//integration_config integration_groups integration_groups_mongodb \
//integration_groups_sql integration_groups_cassandra
但这样做没有起作用。
英文:
I am using multiple Golang build tags in a test suite.
Is there a way to split them into multiple lines in go 1.14?
For instance I want to split this line into multiple lines:
// +build integration integration_auth_pwd integration_auth_tls integration_config integration_groups integration_groups_mongodb integration_groups_sql integration_groups_cassandra
I have tried to split them like this:
// +build integration integration_auth_pwd integration_auth_tls \
//integration_config integration_groups integration_groups_mongodb \
//integration_groups_sql integration_groups_cassandra
This didn't work.
答案1
得分: 2
你不能打破// +build
的约束条件。
你可以指定多个// +build
行。但要知道,一行中用空格分隔的约束条件是逻辑与关系,而多行中的约束条件是逻辑或关系,所以它们是不同的。
你不能将要求分成多行,要使用单行。
友情提示:Go 1.14不再受支持。请使用最新的Go版本。无论在Go 1.14中发现了什么安全漏洞,你将在余生中都会受到其影响。
英文:
You can't break // +build
constraints.
You may specify multiple // +build
lines. But know that space separated constraints in a line are ANDed together, and constraints specified in multiple lines are ORed together, so it's not the same.
You can't break your requirement into multiple lines, use a single line.
A friendly note: Go 1.14 isn't supported anymore. Please do use the latest Go. Whatever security vulnerabilities are discovered in Go 1.14, you'll be vulnerable to those for the rest of your life.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论