Go客户端和'etcdctl'cli实用工具似乎在不同的工作空间上工作,即使它们连接到相同的主机

I wrote a little Go program that connects to etcd hosts http://192.168.0.210:2379 and http://192.168.0.211:2379, sets a key /foo to bar and then reads it and prints the result. That part is working fine:

bar &{get {Key: /foo, CreatedIndex: 6, ModifiedIndex: 6, TTL: 0} <nil> 6 67b31bc85ffd6d2b} <nil>

the key can also be read using a HTTP GET request

{
    "action": "get",
    "node": {
        "key": "/foo",
        "value": "bar",
        "modifiedIndex": 6,
        "createdIndex": 6
    }
}

but when I use ectdctl it returns nothing as if the key didn't exist

./etcdctl --endpoints=192.168.0.210:2379,192.168.0.211:2379 get /foo

if I instead set /foo using etcdctl, then it works and reads the key correctly. It looks like etcdctl is working on a workspace of its own. Any ideas why this is happening?

The issue was I was using API v2 for the client and v3 for the etcdctl. Different API versions have different key namespaces. To use client v3 in Go import go.etcd.io/etcd/clientv3