etcd go clientv3-为什么不遍历结果就无法获取值

I'm trying to learn go and have been doing ok but I have come across behaviour that I can't understand. I guess it is not really to do with etcd?

So, I have etcd v3 setup with a key/value. When I retrieve it with 'get' (see here) I would have expected to be able to retrieve my value using:

fmt.Println(resp.Kvs.Value)

however, this doesn't work and I have to do it as per the example (in the link above) and loop through the single result to expose it:

for _, ev := range resp.Kvs {
fmt.Printf("%s : %s
", ev.Key, ev.Value)
}

Please could you help me understand why retrieving the value directly isn't possible and what is going on that makes the loop necessary?

The response object is the same whether you're getting a single key or many keys, so it must provide for multiple results, even when the total count returned is 1. If you know there's only one result, you're not obliged to loop over it, you can just reference the first result:

resp.Kvs[0].Value

Of course, you should make sure there was a result first (len(resp.Kvs) > 0) or it will panic.