The method PUT is in the interface KV, but the struct Client doesn't implement the the method in interface KV
. So why it can use the method like this:
cli, err := clientv3.New(.....)
cli.Put(...)
The method PUT is in the interface KV, but the struct Client doesn't implement the the method in interface KV
. So why it can use the method like this:
cli, err := clientv3.New(.....)
cli.Put(...)
As per godoc
type Client struct {
Cluster
KV
Lease
Watcher
Auth
Maintenance
// Username is a user name for authentication.
Username string
// Password is a password for authentication.
Password string
// contains filtered or unexported fields
}
It means that a Client
embeds a KV
. So when calling Client.Put()
the Put()
method of KV
is promoted and used instead.
Read more: https://golang.org/ref/spec#Struct_types