dongrong7883 2019-07-05 07:17
浏览 43
已采纳

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

I'm trying to used github.com/spf13/viper which requires github.com/spf13/afero and that requires some of the 3rdparty/go/golang.org/x/text: packages. Till afero works, and when defining 3rdparty BUILD for text:* packages I get the following errors,

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)

I tried to define it like this in 3rdparty/go/golang.org/x/text/BUILD,

go_remote_library(
    rev='342b2e1fbaa52c93f31447ad2c6abc048c63e475',
    packages=[
        'unicode/norm',
        'transform',
    ]
)

And it still shows the same error. Plus now running buildgen.go fails with the following error,

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

Some more info, - Pants version: 1.13.0 - pantsbuild.pants.contrib.go: 1.13.0 - Tried using 1.14.0 & 1.15.0 as well and got the same results

Simple example to recreate it,

package main

import (
    "fmt"

    "github.com/spf13/viper"
)

func main() {
    viper.AutomaticEnv()
    fmt.Printf("%s", viper.GetString("HOME"))
}

Also you can simply do pants resolve on the package to get the error,

pants resolve 3rdparty/go/github.com/spf13/viper
  • 写回答

1条回答 默认 最新

  • douyun8674 2019-07-07 06:03
    关注

    Thanks to the pants team, got the issue resolved.

    buildgen.go does turn go_remote_library(pkg='foo') takes into go_remote_libraries targets. We need to use go_remote_libraries (not go_remote_library) to specify multiple packages.

    Using this works fine,

    go_remote_libraries(
      rev='342b2e1fbaa52c93f31447ad2c6abc048c63e475',
      packages=[
        'transform',
        'unicode/norm',
      ]
    )
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀