etcd-io / etcd

Distributed reliable key-value store for the most critical data of a distributed system
https://etcd.io
Apache License 2.0
46.8k stars 9.65k forks source link

module declares its path as: go.etcd.io/bbolt,but was required as: github.com/coreos/bbolt #11749

Closed daheige closed 2 years ago

daheige commented 4 years ago

my code:

package main

import (
    "context"
    "encoding/json"
    "fmt"
    "log"
    "os"
    "os/signal"
    "syscall"
    "time"

    "go.etcd.io/etcd/v3/clientv3"
)

var endPoints = []string{
    "192.168.0.11:2379",
    //  "192.168.0.12:2379",
    //   "192.168.0.13:2379",
}

var wait = 3 * time.Second

func main() {
    log.Println("test etcd")
    cli, err := clientv3.New(clientv3.Config{
        Endpoints:   endPoints,
        DialTimeout: 5 * time.Second,
    })

    if err != nil {
        // handle error
        log.Fatalln("etcd connection error: ", err)
    }

    defer cli.Close()

    // 设置超时
    ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
    _, err = cli.Put(ctx, "name", "Jaye")
    defer cancel()
    if err != nil {
        log.Println("cli.Put", err.Error())
    }

    // 取值
    ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second)
    res, err := cli.Get(ctx, "/test/ok")
    if err != nil {
        log.Println("cli.Get", err.Error())
    }

    for k, v := range res.Kvs {
        fmt.Println("查询结果", k, string(v.Key), string(v.Value))
    }

    // watch
    // for {
    //  rch := cli.Watch(context.Background(), "home")
    //  for resp := range rch {
    //      for k, v := range resp.Events {
    //          fmt.Println(k, v.Type, string(v.Kv.Key), string(v.Kv.Value))
    //      }
    //  }
    // }

    watchConfig(cli, "config_key", &appConfig)

    //平滑重启
    ch := make(chan os.Signal, 1)
    // We'll accept graceful shutdowns when quit via SIGINT (Ctrl+C)
    // recivie signal to exit main goroutine
    // window signal
    signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, syscall.SIGHUP)

    // linux signal if you use linux on production,please use this code.
    // signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM, syscall.SIGUSR2, os.Interrupt, syscall.SIGHUP)

    // Block until we receive our signal.
    sig := <-ch

    log.Println("exit signal: ", sig.String())
    // Create a deadline to wait for.
    ctx, cancel = context.WithTimeout(context.Background(), wait)
    defer cancel()

    <-ctx.Done()

    log.Println("shutting down")
}

// AppConfig 应用config
type AppConfig struct {
    AppID   string `json:"app_id"`
    AppName string `json:"app_name`
}

var appConfig AppConfig

// watchConfig 监听配置变化
func watchConfig(clt *clientv3.Client, key string, ss interface{}) {
    watchCh := clt.Watch(context.TODO(), key)
    go func() {
        for res := range watchCh {
            value := res.Events[0].Kv.Value
            if err := json.Unmarshal(value, ss); err != nil {
                fmt.Println("now", time.Now(), "watchConfig err", err)
                continue
            }
            fmt.Println("now", time.Now(), "watchConfig", ss)
        }
    }()
}

$ go mod tidy
go.etcd.io/etcd/clientv3 tested by go.etcd.io/etcd/clientv3.test imports github.com/coreos/etcd/auth imports github.com/coreos/etcd/mvcc/backend imports github.com/coreos/bbolt: github.com/coreos/bbolt@v1.3.4: parsing go.mod: module declares its path as: go.etcd.io/bbolt but was required as: github.com/coreos/bbolt

daheige commented 4 years ago

$ go run app.go

github.com/coreos/etcd/clientv3/balancer/picker

/mygo/pkg/mod/github.com/coreos/etcd@v3.3.20+incompatible/clientv3/balancer/picker/err.go:37:44: undefined: balancer.PickOptions /mygo/pkg/mod/github.com/coreos/etcd@v3.3.20+incompatible/clientv3/balancer/picker/roundrobin_balanced.go:55:54: undefined: balancer.PickOptions

github.com/coreos/etcd/clientv3/balancer/resolver/endpoint

/mygo/pkg/mod/github.com/coreos/etcd@v3.3.20+incompatible/clientv3/balancer/resolver/endpoint/endpoint.go:114:78: undefined: resolver.BuildOption /mygo/pkg/mod/github.com/coreos/etcd@v3.3.20+incompatible/clientv3/balancer/resolver/endpoint/endpoint.go:182:31: undefined: resolver.ResolveNowOption

utrack commented 4 years ago

all the undefined errors are happening because of #11721

andrewrynhard commented 4 years ago

@philips Is something similar to #11823 needed to fix this too?

philips commented 4 years ago

I don’t quite understand what is the problem in this setup.

Can someone please retry using:

go get go.etcd.io/etcd/v3/clientv3@master

thanks

andrewrynhard commented 4 years ago

Ran the above, but i think i may be hitting this because of an indirect dependency on github.com/coreos/etcd.

[I] go mod tidy
go: finding module for package github.com/coreos/bbolt
go: found github.com/coreos/bbolt in github.com/coreos/bbolt v1.3.4
go: github.com/talos-systems/talos/internal/app/machined/pkg/system/services imports
    go.etcd.io/etcd/clientv3 tested by
    go.etcd.io/etcd/clientv3.test imports
    github.com/coreos/etcd/auth imports
    github.com/coreos/etcd/mvcc/backend imports
    github.com/coreos/bbolt: github.com/coreos/bbolt@v1.3.4: parsing go.mod:
    module declares its path as: go.etcd.io/bbolt
            but was required as: github.com/coreos/bbolt
philips commented 4 years ago

Hrm, I don't know where github.com/coreos/bbolt could be coming from. But, it doesn't appear anywhere except CHANGELOGs in this repo's master.

On Tue, Apr 28, 2020 at 4:05 PM Andrew Rynhard notifications@github.com wrote:

Ran the above, but i think i may be hitting this because of an indirect dependency on github.com/coreos/etcd.

[I] go mod tidy go: finding module for package github.com/coreos/bbolt go: found github.com/coreos/bbolt in github.com/coreos/bbolt v1.3.4 go: github.com/talos-systems/talos/internal/app/machined/pkg/system/services imports go.etcd.io/etcd/clientv3 tested by go.etcd.io/etcd/clientv3.test imports github.com/coreos/etcd/auth imports github.com/coreos/etcd/mvcc/backend imports github.com/coreos/bbolt: github.com/coreos/bbolt@v1.3.4: parsing go.mod: module declares its path as: go.etcd.io/bbolt but was required as: github.com/coreos/bbolt

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/etcd-io/etcd/issues/11749#issuecomment-620900332, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAIGCBAG7B4IBKFY4ACRDDRO5OMDANCNFSM4MASKARQ .

andrewrynhard commented 4 years ago
[I] go mod tidy -v
go: finding module for package github.com/coreos/bbolt
go: found github.com/coreos/bbolt in github.com/coreos/bbolt v1.3.4
go: github.com/talos-systems/talos/internal/app/machined/pkg/system/services imports
    go.etcd.io/etcd/clientv3 tested by
    go.etcd.io/etcd/clientv3.test imports
    github.com/coreos/etcd/auth imports
    github.com/coreos/etcd/mvcc/backend imports
    github.com/coreos/bbolt: github.com/coreos/bbolt@v1.3.4: parsing go.mod:
    module declares its path as: go.etcd.io/bbolt
            but was required as: github.com/coreos/bbolt
andrewrynhard commented 4 years ago

maybe because of viper?

[I] go mod graph | grep coreos/etcd
github.com/spf13/viper@v1.3.2 github.com/coreos/etcd@v3.3.10+incompatible

go modules hurt my brain sometimes

philips commented 4 years ago

I don’t know how we can fix this without going back in time. Master of viper seems to have dropped this: https://github.com/spf13/viper/blob/master/go.mod

shnish commented 4 years ago

Is there any workaround that those of us who require go mod can use? I tried to go back a few minor versions but found that this issue happens with each one.

utrack commented 4 years ago

@shnish you can try this fork https://github.com/etcd-io/etcd/issues/11721#issuecomment-620581898 while maintainers are fixing the problem. It should work just fine

nektro commented 4 years ago

why did bbolt switch to using go.etcd.io/bbolt in the first place?

as opposed to using the more obvious github.com/etcd-io/etcd or github.com/coreos/bbolt ?

rustyx commented 3 years ago

The etcd project should search and replace github.com/coreos/ with go.etcd.io/ in their source (why, why did you change it?!)

Meanwhile, add this to go.mod to get the code to compile:

replace github.com/coreos/bbolt => go.etcd.io/bbolt v1.3.5
2build commented 3 years ago

try downgrade the version in go.mod

github.com/coreos/bbolt v1.3.4  => github.com/coreos/bbolt v1.3.3
mohdahmad17 commented 3 years ago

@2build my go mod file doesn't include bbolt. It only has github.com/coreos/etcd v3.3.20+incompatible. Any suggested workarounds apart from using the fork?

2build commented 3 years ago

@mohdahmad17 Maybe, you can downgrade etcd version and add bbolt manually. I'm new to golang, here is my full gomod file, it worked in my test project.

go 1.15

require (
    github.com/coreos/bbolt v1.3.3 // indirect
    github.com/coreos/etcd v3.3.13+incompatible
    github.com/coreos/go-semver v0.3.0 // indirect
    github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
    github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
    github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
    github.com/gogo/protobuf v1.3.1 // indirect
    github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
    github.com/google/btree v1.0.0 // indirect
    github.com/google/go-cmp v0.5.1 // indirect
    github.com/gorilla/websocket v1.4.2 // indirect
    github.com/grpc-ecosystem/go-grpc-middleware v1.2.0 // indirect
    github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
    github.com/grpc-ecosystem/grpc-gateway v1.11.3 // indirect
    github.com/jonboulle/clockwork v0.2.1 // indirect
    github.com/prometheus/client_golang v1.7.1 // indirect
    github.com/soheilhy/cmux v0.1.4 // indirect
    github.com/tmc/grpc-websocket-proxy v0.0.0-20200427203606-3cfed13b9966 // indirect
    github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
    go.etcd.io/bbolt v1.3.3 // indirect
    go.uber.org/zap v1.16.0 // indirect
    golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
    golang.org/x/net v0.0.0-20200707034311-ab3426394381 // indirect
    golang.org/x/sys v0.0.0-20200803210538-64077c9b5642 // indirect
    golang.org/x/text v0.3.3 // indirect
    golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect
    golang.org/x/tools v0.0.0-20200806022845-90696ccdc692 // indirect
    golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
    google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1 // indirect
    google.golang.org/grpc v1.22.0 // indirect
    honnef.co/go/tools v0.0.1-2020.1.4 // indirect
)
billiamx33 commented 3 years ago

Mr Tabor pointed me to this posting -- Thank you Mr. Tabor !

I used the earlier go.mods contents posted, but also modifed the following files in the latests etcd module in ~/go/pkg/mod/go.etcd.io/etcd@v3.3.25+incompatible to address go.etcd.io/bbolt instead:

bill-of-materials.json: "project": "github.com/coreos/bbolt", clientv3/snapshot/v3_snapshot.go: bolt "github.com/coreos/bbolt" etcdctl/ctlv2/command/backup_command.go: bolt "github.com/coreos/bbolt" etcdctl/ctlv3/command/snapshot_command.go: bolt "github.com/coreos/bbolt" glide.lock:- name: github.com/coreos/bbolt glide.yaml:- package: github.com/coreos/bbolt mvcc/backend/backend.go: bolt "github.com/coreos/bbolt" mvcc/backend/config_windows.go:import bolt "github.com/coreos/bbolt" mvcc/backend/batch_tx_test.go: bolt "github.com/coreos/bbolt" mvcc/backend/backend_test.go: bolt "github.com/coreos/bbolt" mvcc/backend/batch_tx.go: bolt "github.com/coreos/bbolt" mvcc/backend/read_tx.go: bolt "github.com/coreos/bbolt" mvcc/backend/config_default.go:import bolt "github.com/coreos/bbolt" mvcc/backend/config_linux.go: bolt "github.com/coreos/bbolt" snapshot/v3_snapshot.go: bolt "github.com/coreos/bbolt"

When this correction was made the call to 'go build' for my program it corrected the go.mod file to the most current version of go.etcd.io/etcd and go.etcd.io/bbolt.

While not an optimal solution , it worked. Now running the latest etcd and bbolt module libs.

Thanks for the support!

daheige commented 3 years ago

Thank you,i try it again.

发自我的iPhone

------------------ Original ------------------ From: billiamx33 <notifications@github.com> Date: Fri,Oct 23,2020 2:19 AM To: etcd-io/etcd <etcd@noreply.github.com> Cc: heige <1114789385@qq.com>, Author <author@noreply.github.com> Subject: Re: [etcd-io/etcd] module declares its path as: go.etcd.io/bbolt,but was required as: github.com/coreos/bbolt (#11749)

Mr Tabor pointed me to this posting -- Thank you Mr. Tabor !

I used the earlier go.mods contents posted, but also modifed the following files in the latests etcd module in ~/go/pkg/mod/go.etcd.io/etcd@v3.3.25+incompatible to address go.etcd.io/bbolt instead:

bill-of-materials.json: "project": "github.com/coreos/bbolt", clientv3/snapshot/v3_snapshot.go: bolt "github.com/coreos/bbolt" etcdctl/ctlv2/command/backup_command.go: bolt "github.com/coreos/bbolt" etcdctl/ctlv3/command/snapshot_command.go: bolt "github.com/coreos/bbolt" glide.lock:- name: github.com/coreos/bbolt glide.yaml:- package: github.com/coreos/bbolt mvcc/backend/backend.go: bolt "github.com/coreos/bbolt" mvcc/backend/config_windows.go:import bolt "github.com/coreos/bbolt" mvcc/backend/batch_tx_test.go: bolt "github.com/coreos/bbolt" mvcc/backend/backend_test.go: bolt "github.com/coreos/bbolt" mvcc/backend/batch_tx.go: bolt "github.com/coreos/bbolt" mvcc/backend/read_tx.go: bolt "github.com/coreos/bbolt" mvcc/backend/config_default.go:import bolt "github.com/coreos/bbolt" mvcc/backend/config_linux.go: bolt "github.com/coreos/bbolt" snapshot/v3_snapshot.go: bolt "github.com/coreos/bbolt"

When this correction was made the call to 'go build' for my program it corrected the go.mod file to the most current version of go.etcd.io/etcd and go.etcd.io/bbolt.

While not an optimal solution , it worked. Now running the latest etcd and bbolt module libs.

Thanks for the support!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.

daheige commented 3 years ago

@stale @2build think you all.

cupen commented 3 years ago

So, it's still a problem will be with us a long time. : (

daheige commented 3 years ago

Etcd has always been a problem. I hope that the official package can solve the problem of package dependency in a friendly way. If it is only solved by replacement, I think it is a bad solution. I hope the etcd team can improve and do better, which will be conducive to the development of community ecology.

------------------ Original ------------------ From: 咚咔 <notifications@github.com> Date: Mon,Feb 8,2021 0:58 PM To: etcd-io/etcd <etcd@noreply.github.com> Cc: heige <1114789385@qq.com>, Author <author@noreply.github.com> Subject: Re: [etcd-io/etcd] module declares its path as: go.etcd.io/bbolt,but was required as: github.com/coreos/bbolt (#11749)

So, it's still a problem will be with us a long time.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

chenyiping111 commented 3 years ago

塔博尔先生向我指出了这个职位-谢谢塔博尔先生

我用了前面go.mods贴内容,但还有以下体改 在latests ETCD模块文件~/go/pkg/mod/go.etcd.io/etcd@v3.3.25+incompatible 到地址go.etcd.io / bbolt代替:

bill-of-materials.json:“项目”:“ github.com/coreos/bbolt”,clientv3 / snapshot / v3_snapshot.go:螺栓“ github.com/coreos/bbolt” etcdctl / ctlv2 / command / backup_command.go:螺栓“ github.com/coreos/bbolt” etcdctl / ctlv3 / command / snapshot_command.go:螺栓“ github.com/coreos/bbolt” glide.lock:-名称:github.com/coreos/bbolt glide.yaml:-包:github.com/coreos/bbolt mvcc / backend / backend.go:螺栓“ github.com/coreos/bbolt” mvcc / backend / config_windows.go:导入螺栓“ github.com/coreos/bbolt” mvcc / backend / batch_tx_test .go:螺栓“ github.com/coreos/bbolt” mvcc / backend / backend_test.go:螺栓“ github.com/coreos/bbolt” mvcc / backend / batch_tx.go:螺栓“ github.com/coreos/bbolt” mvcc / backend / read_tx.go:螺栓“ github.com/coreos/bbolt” mvcc / backend / config_default.go:import螺栓“ github.com/coreos/bbolt” mvcc / backend / config_linux.go:螺栓“ github.com / coreos / bbolt” 快照/v3_snapshot.go:螺栓“ github.com/coreos/bbolt”

进行此更正后,我的程序调用了“ go build”,它将go.mod文件更正为 最新的go版本。etcd.io/etcdgo.etcd.io/bbolt。

虽然不是最佳解决方案,但它确实有效。现在运行最新的etcd和bbolt模块库。

感谢您的支持!

Mr Tabor pointed me to this posting -- Thank you Mr. Tabor !

I used the earlier go.mods contents posted, but also modifed the following files in the latests etcd module in ~/go/pkg/mod/go.etcd.io/etcd@v3.3.25+incompatible to address go.etcd.io/bbolt instead:

bill-of-materials.json: "project": "github.com/coreos/bbolt", clientv3/snapshot/v3_snapshot.go: bolt "github.com/coreos/bbolt" etcdctl/ctlv2/command/backup_command.go: bolt "github.com/coreos/bbolt" etcdctl/ctlv3/command/snapshot_command.go: bolt "github.com/coreos/bbolt" glide.lock:- name: github.com/coreos/bbolt glide.yaml:- package: github.com/coreos/bbolt mvcc/backend/backend.go: bolt "github.com/coreos/bbolt" mvcc/backend/config_windows.go:import bolt "github.com/coreos/bbolt" mvcc/backend/batch_tx_test.go: bolt "github.com/coreos/bbolt" mvcc/backend/backend_test.go: bolt "github.com/coreos/bbolt" mvcc/backend/batch_tx.go: bolt "github.com/coreos/bbolt" mvcc/backend/read_tx.go: bolt "github.com/coreos/bbolt" mvcc/backend/config_default.go:import bolt "github.com/coreos/bbolt" mvcc/backend/config_linux.go: bolt "github.com/coreos/bbolt" snapshot/v3_snapshot.go: bolt "github.com/coreos/bbolt"

When this correction was made the call to 'go build' for my program it corrected the go.mod file to the most current version of go.etcd.io/etcd and go.etcd.io/bbolt.

While not an optimal solution , it worked. Now running the latest etcd and bbolt module libs.

Thanks for the support!

Mr Tabor pointed me to this posting -- Thank you Mr. Tabor !

I used the earlier go.mods contents posted, but also modifed the following files in the latests etcd module in ~/go/pkg/mod/go.etcd.io/etcd@v3.3.25+incompatible to address go.etcd.io/bbolt instead:

bill-of-materials.json: "project": "github.com/coreos/bbolt", clientv3/snapshot/v3_snapshot.go: bolt "github.com/coreos/bbolt" etcdctl/ctlv2/command/backup_command.go: bolt "github.com/coreos/bbolt" etcdctl/ctlv3/command/snapshot_command.go: bolt "github.com/coreos/bbolt" glide.lock:- name: github.com/coreos/bbolt glide.yaml:- package: github.com/coreos/bbolt mvcc/backend/backend.go: bolt "github.com/coreos/bbolt" mvcc/backend/config_windows.go:import bolt "github.com/coreos/bbolt" mvcc/backend/batch_tx_test.go: bolt "github.com/coreos/bbolt" mvcc/backend/backend_test.go: bolt "github.com/coreos/bbolt" mvcc/backend/batch_tx.go: bolt "github.com/coreos/bbolt" mvcc/backend/read_tx.go: bolt "github.com/coreos/bbolt" mvcc/backend/config_default.go:import bolt "github.com/coreos/bbolt" mvcc/backend/config_linux.go: bolt "github.com/coreos/bbolt" snapshot/v3_snapshot.go: bolt "github.com/coreos/bbolt"

When this correction was made the call to 'go build' for my program it corrected the go.mod file to the most current version of go.etcd.io/etcd and go.etcd.io/bbolt.

While not an optimal solution , it worked. Now running the latest etcd and bbolt module libs.

Thanks for the support!

Have you solved your problem? but I still have the problem "go.etcd.io/bbolt@v1.3.3 used for two different module paths (github.com/coreos/bbolt and github.com/etcd-io/bbolt)", if you already solved,can you give me an reply, I would appreciate it.

bernardhu commented 3 years ago

@chenyiping111

in you go.mod add two lines:

replace ( github.com/coreos/bbolt => go.etcd.io/bbolt v1.3.5 go.uber.org/atomic => github.com/uber-go/atomic v1.5.0 )

hope userful..

bernardhu commented 3 years ago

@chenyiping111

in you go.mod add two lines:

replace ( github.com/coreos/bbolt => go.etcd.io/bbolt v1.3.5 go.uber.org/atomic => github.com/uber-go/atomic v1.5.0 )

hope userful..

daheige commented 3 years ago

thanks,maybe this can resolve it.

------------------ Original ------------------ From: bernardhu <notifications@github.com> Date: Wed,Mar 3,2021 9:10 AM To: etcd-io/etcd <etcd@noreply.github.com> Cc: heige <1114789385@qq.com>, Author <author@noreply.github.com> Subject: Re: [etcd-io/etcd] module declares its path as: go.etcd.io/bbolt,but was required as: github.com/coreos/bbolt (#11749)

@chenyiping111

in you go.mod add two lines:

replace ( github.com/coreos/bbolt => go.etcd.io/bbolt v1.3.5 go.uber.org/atomic => github.com/uber-go/atomic v1.5.0 )

hope userful..

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

charconstpointer commented 3 years ago

First time using etcd go client and it's such a mess

cannot use cli (type "go.etcd.io/etcd/clientv3".Client) as type "github.com/coreos/etcd/clientv3".Client in argument to concurrency.NewSession

package main

import (
    "context"
    "log"
    "time"

    "go.etcd.io/etcd/clientv3"
    "go.etcd.io/etcd/clientv3/concurrency"
)

func main() {
    cli, err := clientv3.New(clientv3.Config{
        Endpoints:   []string{"localhost:2379"},
        DialTimeout: 5 * time.Second,
    })
    if err != nil {
        log.Fatal(err.Error())
    }
    defer cli.Close()

    s, err := concurrency.NewSession(cli)
    if err != nil {
        log.Fatal(err.Error())
    }
    e := concurrency.NewElection(s, "e")
    ctx := context.TODO()

    if err := e.Campaign(ctx, "e"); err != nil {
        log.Fatal(err.Error())
    }

    if err := e.Resign(ctx); err != nil {
        log.Fatal(err.Error())
    }
}

go.mod

go 1.16

replace (
    github.com/coreos/bbolt => go.etcd.io/bbolt v1.3.5
    go.uber.org/atomic => github.com/uber-go/atomic v1.5.0
)

require (
    github.com/coreos/etcd v3.3.25+incompatible // indirect
    github.com/coreos/go-semver v0.3.0 // indirect
    github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
    github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
    github.com/gogo/protobuf v1.3.2 // indirect
    github.com/google/uuid v1.2.0 // indirect
    go.etcd.io/etcd v3.3.25+incompatible
    go.uber.org/zap v1.16.0 // indirect
    google.golang.org/grpc v1.36.0 // indirect
)

any ideas how to fix it?

GwynethLlewelyn commented 3 years ago

Hi! I'm trying to compile a package with lots of dependencies, including bbolt (and, indirectly, etcd). The major problem with that package is that it's still using the now obsolete govendor package; go mod init will certainly attempt to generate a valid go.mod file, but it gets utterly confused with the change from github.com/coreos/bbolt to go.etcd.io/bbolt, giving the error @daheige first mentioned a year ago.

Note that the simplistic approach:

@philips wrote, a year ago:

go get go.etcd.io/etcd/v3/clientv3@master

... does not work any longer:

go get: module go.etcd.io/etcd/v3@master found (v3.5.0-alpha.0.0.20210328231413-a40a6e9ad8a6), but does not contain package go.etcd.io/etcd/v3/clientv3

Using replace as suggested by @rustyx and @bernardhu goes a long way to fix a lot of dependencies and allows go mod tidy to almost hit the finishing line, but, ultimately, it will throw the error

go: go.etcd.io/bbolt@v1.3.5 used for two different module paths (github.com/etcd-io/bbolt and go.etcd.io/bbolt)

and stop.

To make matters worse, go mod graph | grep bbolt will show a plethora of different ways to include the bbolt package:

github.com/ory/viper@v1.5.6 github.com/coreos/bbolt@v1.3.2
github.com/ory/viper@v1.5.6 go.etcd.io/bbolt@v1.3.2
github.com/spf13/viper@v1.7.0 github.com/coreos/bbolt@v1.3.2
github.com/spf13/viper@v1.7.0 go.etcd.io/bbolt@v1.3.2
go.etcd.io/etcd@v0.0.0-20191023171146-3cf2f69b5738 go.etcd.io/bbolt@v1.3.3
github.com/go-swagger/go-swagger@v0.20.0 github.com/coreos/bbolt@v1.3.3
github.com/go-swagger/go-swagger@v0.20.0 go.etcd.io/bbolt@v1.3.3
github.com/spf13/viper@v1.4.0 github.com/coreos/bbolt@v1.3.2
github.com/spf13/viper@v1.4.0 go.etcd.io/bbolt@v1.3.2
github.com/etcd-io/bbolt@v1.3.4 golang.org/x/sys@v0.0.0-20200202164722-d101bd2416d5

I'm now trying to

  1. rename all possible variations of including bbolt to a single one;
  2. if that fails, manually go through all included files and change them, one by one.

That will take me a while, and I'll be glad to post my results here as soon as I finish this daunting task!

ptabor commented 3 years ago
go get go.etcd.io/etcd/v3/clientv3@master

... does not work any longer:

go get go.etcd.io/etcd/client/v3

should be the modern equivalent.

GwynethLlewelyn commented 3 years ago

Thanks @ptabor! You're quite right, that's the modern equivalent indeed...

Unfortunately, now my problems lie elsewhere:

go: github.com/nats-io/nats.go@v1.8.0 used for two different module paths (github.com/nats-io/nats and github.com/nats-io/nats.go)

Don't you just love dependencies? 😉

But at least this is not a problem with etcd any longer...

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.

Clivern commented 3 years ago

i added both and it worked.

module github.com/clivern/peanut

go 1.16

require (
    github.com/coreos/etcd v3.3.25+incompatible // indirect
    go.etcd.io/etcd v3.3.25+incompatible
)
daheige commented 3 years ago

OK, I'll try. Thank you. I don't know if the higher version has solved this problem. I think the community has adopted the replacement mode to solve this problem. I expect the official to solve this dependency problem.

------------------ Original ------------------ From: Ahmed @.> Date: Fri,Jul 2,2021 3:00 AM To: etcd-io/etcd @.> Cc: heige @.>, Mention @.> Subject: Re: [etcd-io/etcd] module declares its path as: go.etcd.io/bbolt,but was required as: github.com/coreos/bbolt (#11749)

i added both and it worked. module github.com/clivern/peanut go 1.16 require ( github.com/coreos/etcd v3.3.25+incompatible // indirect go.etcd.io/etcd v3.3.25+incompatible )

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.

1055373165 commented 2 years ago

in go.mod add

replace github.com/coreos/bbolt => go.etcd.io/bbolt v1.3.6

replace google.golang.org/grpc => google.golang.org/grpc v1.26.0

RiflerRick commented 2 years ago

thanks, that worked for me