【问题标题】:Having issue defining go_remote_library declaration for 3rdparty/go/golang.org/x/text:*为 3rdparty/go/golang.org/x/text 定义 go_remote_library 声明时遇到问题:*
【发布时间】:2019-07-05 07:17:53
【问题描述】:

我正在尝试使用 github.com/spf13/viper,它需要 github.com/spf13/afero 并且需要一些 3rdparty/go/golang.org/x/text: 包。直到 afero 工作,并且在为 text:* 包定义 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 3rdparty/go/github.com/spf13/viper

【问题讨论】:

    标签: go pants


    【解决方案1】:

    感谢裤子团队,问题得到解决。

    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',
      ]
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多