我正在尝试使用 github.com/spf13/viper,它需要 github.com/spf13/afero 并且需要一些 3rdparty/go/golang.org/x/text: 包。直到 afero 工作,并且在为文本定义 3rdparty BUILD 时:* 包我得到以下错误,
3rdparty/go/github.com/spf13/afero has remote dependencies which require local declaration:
--> golang.org/x/text/unicode/norm (expected go_remote_library declaration at 3rdparty/go/golang.org/x/text:unicode/norm)
--> golang.org/x/text/transform (expected go_remote_library declaration at 3rdparty/go/golang.org/x/text:transform)
我试着在 3rdparty/go/golang.org/x/text/BUILD 中这样定义它,
go_remote_library(
rev='342b2e1fbaa52c93f31447ad2c6abc048c63e475',
packages=[
'unicode/norm',
'transform',
]
)
它仍然显示相同的错误。另外现在运行 buildgen.go 失败并出现以下错误,
Exception caught: (pants.build_graph.target.UnknownArgumentError) (backtrace omitted)
Exception message: Invalid target 3rdparty/go/golang.org/x/text:text: GoRemoteLibrary received unknown arguments:
packages = ['unicode/norm', 'transform']
更多信息, - 裤子版本:1.13.0 - pantsbuild.pants.contrib.go:1.13.0 - 也尝试使用 1.14.0 和 1.15.0 并得到相同的结果
重新创建它的简单示例,
package main
import (
"fmt"
"github.com/spf13/viper"
)
func main() {
viper.AutomaticEnv()
fmt.Printf("%s", viper.GetString("HOME"))
}
你也可以简单地在包上做 pants resolve 来得到错误,
pants resolve 3rdparty/go/github.com/spf13/viper
最佳答案
感谢裤子团队,解决了问题。
buildgen.go 确实将 go_remote_library(pkg='foo')
纳入 go_remote_libraries 目标。
我们需要使用 go_remote_libraries
(不是 go_remote_library)来指定多个包。
使用这个效果很好,
go_remote_libraries(
rev='342b2e1fbaa52c93f31447ad2c6abc048c63e475',
packages=[
'transform',
'unicode/norm',
]
)
关于go - 为 3rdparty/go/golang.org/x/text :* 定义 go_remote_library 声明时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56898287/