为 3rdparty/go/golang.org/x/text 定义 go_remote_library 声明时出现问题:*

Having issue defining go_remote_library declaration for 3rdparty/go/golang.org/x/text:*

我正在尝试使用 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',
  ]
)