栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Go语言

Goland的包依赖 Replace处理 排查

Go语言 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Goland的包依赖 Replace处理 排查

…/…/…/…/gowork/pkg/mod/github.com/gogf/gf@v1.16.6/net/ghttp/internal/client/client_tracing.go:73:3: undefined: attribute.Any
…/…/…/…/gowork/pkg/mod/github.com/gogf/gf@v1.16.6/net/ghttp/internal/client/client_tracing_tracer.go:150:3: undefined: attribute.Any
…/…/…/…/gowork/pkg/mod/github.com/gogf/gf@v1.16.6/net/ghttp/internal/client/client_tracing_tracer.go:151:3: undefined: attribute.Any

用GoFrame1.16.6 和Kratos2.1.2开发,都依赖了 go.opentelemetry.io/otel
Kratos写好的打成包,在Goframe里面引用,然后就出错了。

Kratos 引用的是otel v1.2.0
GoFrame 引用的是 v1.0.0-RC2

使用 go mod tidy 的时候会使用 v1.2.0 而 v1.2.0版本没有attribute.Any方法

尝试将 Kratos 的依赖降级为 v1.0.0-RC2 不行,就是要 v1.2.0

解决:在go.mod 里面使用replace语法

Goframe:

replace go.opentelemetry.io/otel => go.opentelemetry.io/otel v1.0.0-RC2

replace go.opentelemetry.io/otel/trace => go.opentelemetry.io/otel/trace v1.0.0-RC2

Kratos:

replace go.opentelemetry.io/otel => go.opentelemetry.io/otel v1.2.0

replace go.opentelemetry.io/otel/trace => go.opentelemetry.io/otel/trace v1.2.0

replace go.opentelemetry.io/otel/exporters/jaeger => go.opentelemetry.io/otel/exporters/jaeger v1.2.0

require 为各自所需依赖的版本号(可能没有)

排查

go get github.com/gogf/gf-tracing
错误:
go get: github.com/gogf/gf-tracing@v0.0.0-20211121144254-0ec23be54000 requires
github.com/gogf/katyusha@v0.1.3-0.20210402080039-f9c0f380474e requires
go.etcd.io/etcd/api/v3@v3.5.0-pre: reading https://goproxy.cn/go.etcd.io/etcd/api/v3/@v/v3.5.0-pre.mod: 404 Not Found
server response: not found: go.etcd.io/etcd/api/v3@v3.5.0-pre: invalid version: unknown revision api/v3.5.0-pre

用go mod why “包名” 排查

usage: go mod why [-m] [-vendor] packages...

Why shows a shortest path in the import graph from the main module to
each of the listed packages. If the -m flag is given, why treats the
arguments as a list of modules and finds a path to any package in each
of the modules.

By default, why queries the graph of packages matched by "go list all",
which includes tests for reachable packages. The -vendor flag causes why
to exclude tests of dependencies.

The output is a sequence of stanzas, one for each package or module
name on the command line, separated by blank lines. Each stanza begins
with a comment line "# package" or "# module" giving the target
package or module. Subsequent lines give a path through the import
graph, one package per line. If the package or module is not
referenced from the main module, the stanza will display a single
parenthesized note indicating that fact.

For example:

        $ go mod why golang.org/x/text/language golang.org/x/text/encoding
        # golang.org/x/text/language
        rsc.io/quote
        rsc.io/sampler
        golang.org/x/text/language

        # golang.org/x/text/encoding
        (main module does not need package golang.org/x/text/encoding)
        $

See https://golang.org/ref/mod#go-mod-why for more about 'go mod why'.

使用 https://pkg.go.dev/ 查询包版本

例如 :
tracing package - github.com/gogf/gf-tracing/tracing - pkg.go.dev
https://pkg.go.dev/github.com/gogf/gf-tracing/tracing


查看go.mod


继续找包

github.com/gogf/katyusha 依赖

这里用到是 go.etcd.io/etcd/api/v3@v3.5.0 不是自动下载的go.etcd.io/etcd/api/v3@v3.5.0-pre 迷惑

找本地的源文件,发现没有。。。。 执行go get github.com/gogf/katyusha 下载下来的是v0.2.0
而报错的是github.com/gogf/katyusha@v0.1.3-0.20210402080039-f9c0f380474e

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/990603.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号