gitee.com/liuxuezhan/go-micro-v1.18.0@v1.0.0/registry/etcd/options.go (about) 1 package etcd 2 3 import ( 4 "context" 5 6 "gitee.com/liuxuezhan/go-micro-v1.18.0/registry" 7 ) 8 9 type authKey struct{} 10 11 type authCreds struct { 12 Username string 13 Password string 14 } 15 16 // Auth allows you to specify username/password 17 func Auth(username, password string) registry.Option { 18 return func(o *registry.Options) { 19 if o.Context == nil { 20 o.Context = context.Background() 21 } 22 o.Context = context.WithValue(o.Context, authKey{}, &authCreds{Username: username, Password: password}) 23 } 24 }