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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

nickdlk

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值