登录
首页 >  Golang >  Go问答

遇到 go_remote_library 声明时如何为 3rdparty/go/golang.org/x/text:* 进行定义

来源:stackoverflow

时间:2024-03-07 11:42:26 433浏览 收藏

怎么入门Golang编程?需要学习哪些知识点?这是新手们刚接触编程时常见的问题;下面golang学习网就来给大家整理分享一些知识点,希望能够给初学者一些帮助。本篇文章就来介绍《遇到 go_remote_library 声明时如何为 3rdparty/go/golang.org/x/text:* 进行定义》,涉及到,有需要的可以收藏一下

问题内容

我正在尝试使用 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 -裤子build.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

解决方案


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

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_remote_library 声明时如何为 3rdparty/go/golang.org/x/text:* 进行定义》的介绍应该让你收获多多了吧!欢迎大家收藏或分享给更多需要学习的朋友吧~golang学习网公众号也会发布Golang相关知识,快来关注吧!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>