From b354f185c04421bd81c8890f89f2079f1f976691 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=85=E5=AD=90?= Date: Fri, 26 Aug 2022 10:54:02 +0800 Subject: [PATCH 01/46] feat(registry): consul support user custom checks (#2317) --- contrib/registry/consul/client.go | 5 +++++ contrib/registry/consul/registry.go | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/contrib/registry/consul/client.go b/contrib/registry/consul/client.go index e97ec7e42..1b39975a0 100644 --- a/contrib/registry/consul/client.go +++ b/contrib/registry/consul/client.go @@ -29,6 +29,8 @@ type Client struct { heartbeat bool // deregisterCriticalServiceAfter time interval in seconds deregisterCriticalServiceAfter int + // serviceChecks user custom checks + serviceChecks api.AgentServiceChecks } // NewClient creates consul client @@ -139,6 +141,9 @@ func (c *Client) Register(_ context.Context, svc *registry.ServiceInstance, enab }) } + // custom checks + asr.Checks = append(asr.Checks, c.serviceChecks...) + err := c.cli.Agent().ServiceRegister(asr) if err != nil { return err diff --git a/contrib/registry/consul/registry.go b/contrib/registry/consul/registry.go index 9da95d77b..d1c47d774 100644 --- a/contrib/registry/consul/registry.go +++ b/contrib/registry/consul/registry.go @@ -63,6 +63,15 @@ func WithDeregisterCriticalServiceAfter(interval int) Option { } } +// WithServiceCheck with service checks +func WithServiceCheck(checks ...*api.AgentServiceCheck) Option { + return func(o *Registry) { + if o.cli != nil { + o.cli.serviceChecks = checks + } + } +} + // Config is consul registry config type Config struct { *api.Config From 361391732b93dcad750177d90557f69dd94fd431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B7=9D=E6=A1=91?= <1554694323@qq.com> Date: Mon, 29 Aug 2022 09:27:44 +0800 Subject: [PATCH 02/46] test(selector): improve coverage (#2320) * test(selector): improve coverage * style: gofumpt --- selector/selector_test.go | 116 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/selector/selector_test.go b/selector/selector_test.go index f7c1f1bcf..bcc08264b 100644 --- a/selector/selector_test.go +++ b/selector/selector_test.go @@ -12,6 +12,8 @@ import ( "github.com/go-kratos/kratos/v2/registry" ) +var errNodeNotMatch = errors.New("node is not match") + type mockWeightedNode struct { Node @@ -80,6 +82,18 @@ func (b *mockBalancer) Pick(ctx context.Context, nodes []WeightedNode) (selected return } +type mockMustErrorBalancerBuilder struct{} + +func (b *mockMustErrorBalancerBuilder) Build() Balancer { + return &mockMustErrorBalancer{} +} + +type mockMustErrorBalancer struct{} + +func (b *mockMustErrorBalancer) Pick(ctx context.Context, nodes []WeightedNode) (selected WeightedNode, done DoneFunc, err error) { + return nil, nil, errNodeNotMatch +} + func TestDefault(t *testing.T) { builder := DefaultBuilder{ Node: &mockWeightedNodeBuilder{}, @@ -107,6 +121,7 @@ func TestDefault(t *testing.T) { Endpoints: []string{"http://127.0.0.1:9090"}, Metadata: map[string]string{"weight": "10"}, })) + selector.Apply(nodes) n, done, err := selector.Select(context.Background(), WithNodeFilter(mockFilter("v2.0.0"))) if err != nil { @@ -121,6 +136,9 @@ func TestDefault(t *testing.T) { if !reflect.DeepEqual("v2.0.0", n.Version()) { t.Errorf("expect %v, got %v", "v2.0.0", n.Version()) } + if n.Scheme() == "" { + t.Errorf("expect %v, got %v", "", n.Scheme()) + } if n.Address() == "" { t.Errorf("expect %v, got %v", "", n.Address()) } @@ -135,6 +153,21 @@ func TestDefault(t *testing.T) { } done(context.Background(), DoneInfo{}) + // peer in ctx + ctx := NewPeerContext(context.Background(), &Peer{ + Node: mockWeightedNode{}, + }) + n, done, err = selector.Select(ctx) + if err != nil { + t.Errorf("expect %v, got %v", ErrNoAvailable, err) + } + if done == nil { + t.Errorf("expect %v, got %v", nil, done) + } + if n == nil { + t.Errorf("expect %v, got %v", nil, n) + } + // no v3.0.0 instance n, done, err = selector.Select(context.Background(), WithNodeFilter(mockFilter("v3.0.0"))) if !errors.Is(ErrNoAvailable, err) { @@ -172,4 +205,87 @@ func TestDefault(t *testing.T) { if n != nil { t.Errorf("expect %v, got %v", nil, n) } + + // without node_filters + n, done, err = selector.Select(context.Background()) + if !errors.Is(ErrNoAvailable, err) { + t.Errorf("expect %v, got %v", ErrNoAvailable, err) + } + if done != nil { + t.Errorf("expect %v, got %v", nil, done) + } + if n != nil { + t.Errorf("expect %v, got %v", nil, n) + } +} + +func TestWithoutApply(t *testing.T) { + builder := DefaultBuilder{ + Node: &mockWeightedNodeBuilder{}, + Balancer: &mockBalancerBuilder{}, + } + selector := builder.Build() + n, done, err := selector.Select(context.Background()) + if !errors.Is(ErrNoAvailable, err) { + t.Errorf("expect %v, got %v", ErrNoAvailable, err) + } + if done != nil { + t.Errorf("expect %v, got %v", nil, done) + } + if n != nil { + t.Errorf("expect %v, got %v", nil, n) + } +} + +func TestNoPick(t *testing.T) { + builder := DefaultBuilder{ + Node: &mockWeightedNodeBuilder{}, + Balancer: &mockMustErrorBalancerBuilder{}, + } + var nodes []Node + nodes = append(nodes, NewNode( + "http", + "127.0.0.1:8080", + ®istry.ServiceInstance{ + ID: "127.0.0.1:8080", + Name: "helloworld", + Version: "v2.0.0", + Endpoints: []string{"http://127.0.0.1:8080"}, + Metadata: map[string]string{"weight": "10"}, + })) + nodes = append(nodes, NewNode( + "http", + "127.0.0.1:9090", + ®istry.ServiceInstance{ + ID: "127.0.0.1:9090", + Name: "helloworld", + Version: "v1.0.0", + Endpoints: []string{"http://127.0.0.1:9090"}, + Metadata: map[string]string{"weight": "10"}, + })) + selector := builder.Build() + selector.Apply(nodes) + n, done, err := selector.Select(context.Background()) + if !errors.Is(errNodeNotMatch, err) { + t.Errorf("expect %v, got %v", errNodeNotMatch, err) + } + if done != nil { + t.Errorf("expect %v, got %v", nil, done) + } + if n != nil { + t.Errorf("expect %v, got %v", nil, n) + } +} + +func TestGolobal(t *testing.T) { + builder := DefaultBuilder{ + Node: &mockWeightedNodeBuilder{}, + Balancer: &mockBalancerBuilder{}, + } + SetGlobalSelector(&builder) + + gBuilder := GlobalSelector() + if gBuilder == nil { + t.Errorf("expect %v, got %v", nil, gBuilder) + } } From 890bc21ac17e4196ddc5a576d1d945608575786d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=85=E5=AD=90?= Date: Wed, 31 Aug 2022 21:04:14 +0800 Subject: [PATCH 03/46] docs: update readme.md, remove qq group (#2341) --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index f4023812c..815be2fc5 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,6 @@ If you discover a security vulnerability within Kratos, please send an e-mail to - [Wechat Group](https://github.com/go-kratos/kratos/issues/682) - [Discord Group](https://discord.gg/BWzJsUJ) - [go-kratos.dev](https://go-kratos.dev/en) -- QQ Group: 716486124 ## Contributors From 20c2425c18d7cf18393a1899e72e576749dc799a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=99=AB=E5=AD=90=E6=A8=B1=E6=A1=83?= Date: Wed, 31 Aug 2022 21:35:38 +0800 Subject: [PATCH 04/46] =?UTF-8?q?fix=20`kratos=20new=20-r`=20not=20support?= =?UTF-8?q?=20scp=20styled=20git=20url.issue=20https://gith=E2=80=A6=20(#2?= =?UTF-8?q?295)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix `kratos new -r` not support scp styled git url.issue https://github.com/go-kratos/kratos/issues/2294 * fix lint * fix lint * remove tail space and add test case Co-authored-by: czyt Co-authored-by: czyt --- cmd/kratos/internal/base/repo.go | 34 ++++++-------- cmd/kratos/internal/base/repo_test.go | 50 +++++++++++++------- cmd/kratos/internal/base/vcs_url.go | 58 ++++++++++++++++++++++++ cmd/kratos/internal/base/vcs_url_test.go | 55 ++++++++++++++++++++++ 4 files changed, 162 insertions(+), 35 deletions(-) create mode 100644 cmd/kratos/internal/base/vcs_url.go create mode 100644 cmd/kratos/internal/base/vcs_url_test.go diff --git a/cmd/kratos/internal/base/repo.go b/cmd/kratos/internal/base/repo.go index 55b12ac0d..bdcb3f010 100644 --- a/cmd/kratos/internal/base/repo.go +++ b/cmd/kratos/internal/base/repo.go @@ -3,13 +3,15 @@ package base import ( "context" "fmt" - stdurl "net/url" + "net" "os" "os/exec" "path" "strings" ) +var unExpandVarPath = []string{"~", ".", ".."} + // Repo is git repository manager. type Repo struct { url string @@ -18,27 +20,21 @@ type Repo struct { } func repoDir(url string) string { - if !strings.Contains(url, "//") { - url = "//" + url - } - if strings.HasPrefix(url, "//git@") { - url = "ssh:" + url - } else if strings.HasPrefix(url, "//") { - url = "https:" + url + vcsURL, err := ParseVCSUrl(url) + if err != nil { + return url } - u, err := stdurl.Parse(url) - if err == nil { - url = fmt.Sprintf("%s://%s%s", u.Scheme, u.Hostname(), u.Path) + // check host contains port + host, _, err := net.SplitHostPort(vcsURL.Host) + if err != nil { + host = vcsURL.Host } - var start int - start = strings.Index(url, "//") - if start == -1 { - start = strings.Index(url, ":") + 1 - } else { - start += 2 + for _, p := range unExpandVarPath { + host = strings.TrimLeft(host, p) } - end := strings.LastIndex(url, "/") - return url[start:end] + dir := path.Base(path.Dir(vcsURL.Path)) + url = fmt.Sprintf("%s/%s", host, dir) + return url } // NewRepo new a repository manager. diff --git a/cmd/kratos/internal/base/repo_test.go b/cmd/kratos/internal/base/repo_test.go index 15ed33c8c..dfcdbb93c 100644 --- a/cmd/kratos/internal/base/repo_test.go +++ b/cmd/kratos/internal/base/repo_test.go @@ -7,7 +7,37 @@ import ( ) func TestRepo(t *testing.T) { - os.RemoveAll("/tmp/test_repo") + urls := []string{ + // ssh://[user@]host.xz[:port]/path/to/repo.git/ + "ssh://git@github.com:7875/go-kratos/kratos.git", + // git://host.xz[:port]/path/to/repo.git/ + "git://github.com:7875/go-kratos/kratos.git", + // http[s]://host.xz[:port]/path/to/repo.git/ + "https://github.com:7875/go-kratos/kratos.git", + // ftp[s]://host.xz[:port]/path/to/repo.git/ + "ftps://github.com:7875/go-kratos/kratos.git", + //[user@]host.xz:path/to/repo.git/ + "git@github.com:go-kratos/kratos.git", + // ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/ + "ssh://git@github.com:7875/go-kratos/kratos.git", + // git://host.xz[:port]/~[user]/path/to/repo.git/ + "git://github.com:7875/go-kratos/kratos.git", + //[user@]host.xz:/~[user]/path/to/repo.git/ + "git@github.com:go-kratos/kratos.git", + ///path/to/repo.git/ + "//github.com/go-kratos/kratos.git", + // file:///path/to/repo.git/ + "file://./github.com/go-kratos/kratos.git", + } + for _, url := range urls { + dir := repoDir(url) + if dir != "github.com/go-kratos" && dir != "/go-kratos" { + t.Fatal(url, "repoDir test failed", dir) + } + } +} + +func TestRepoClone(t *testing.T) { r := NewRepo("https://github.com/go-kratos/service-layout.git", "") if err := r.Clone(context.Background()); err != nil { t.Fatal(err) @@ -15,19 +45,7 @@ func TestRepo(t *testing.T) { if err := r.CopyTo(context.Background(), "/tmp/test_repo", "github.com/go-kratos/kratos-layout", nil); err != nil { t.Fatal(err) } - urls := []string{ - "ssh://git@gitlab.xxx.com:1234/foo/bar.git", - "ssh://gitlab.xxx.com:1234/foo/bar.git", - "//git@gitlab.xxx.com:1234/foo/bar.git", - "git@gitlab.xxx.com:1234/foo/bar.git", - "gitlab.xxx.com:1234/foo/bar.git", - "gitlab.xxx.com/foo/bar.git", - "gitlab.xxx.com/foo/bar", - } - for _, url := range urls { - dir := repoDir(url) - if dir != "gitlab.xxx.com/foo" { - t.Fatal("repoDir test failed", dir) - } - } + t.Cleanup(func() { + os.RemoveAll("/tmp/test_repo") + }) } diff --git a/cmd/kratos/internal/base/vcs_url.go b/cmd/kratos/internal/base/vcs_url.go new file mode 100644 index 000000000..ef76db30f --- /dev/null +++ b/cmd/kratos/internal/base/vcs_url.go @@ -0,0 +1,58 @@ +package base + +import ( + "errors" + "net/url" + "regexp" + "strings" +) + +var ( + scpSyntaxRe = regexp.MustCompile(`^([a-zA-Z0-9_]+)@([a-zA-Z0-9._-]+):(.*)$`) + scheme = []string{"git", "https", "http", "git+ssh", "ssh", "file", "ftp", "ftps"} +) + +// ParseVCSUrl ref https://github.com/golang/go/blob/master/src/cmd/go/internal/vcs/vcs.go +// see https://go-review.googlesource.com/c/go/+/12226/ +// git url define https://git-scm.com/docs/git-clone#_git_urls +func ParseVCSUrl(repo string) (*url.URL, error) { + var ( + repoURL *url.URL + err error + ) + + if m := scpSyntaxRe.FindStringSubmatch(repo); m != nil { + // Match SCP-like syntax and convert it to a URL. + // Eg, "git@github.com:user/repo" becomes + // "ssh://git@github.com/user/repo". + repoURL = &url.URL{ + Scheme: "ssh", + User: url.User(m[1]), + Host: m[2], + Path: m[3], + } + } else { + if !strings.Contains(repo, "//") { + repo = "//" + repo + } + if strings.HasPrefix(repo, "//git@") { + repo = "ssh:" + repo + } else if strings.HasPrefix(repo, "//") { + repo = "https:" + repo + } + repoURL, err = url.Parse(repo) + if err != nil { + return nil, err + } + } + + // Iterate over insecure schemes too, because this function simply + // reports the state of the repo. If we can't see insecure schemes then + // we can't report the actual repo URL. + for _, s := range scheme { + if repoURL.Scheme == s { + return repoURL, nil + } + } + return nil, errors.New("unable to parse repo url") +} diff --git a/cmd/kratos/internal/base/vcs_url_test.go b/cmd/kratos/internal/base/vcs_url_test.go new file mode 100644 index 000000000..09b8d5682 --- /dev/null +++ b/cmd/kratos/internal/base/vcs_url_test.go @@ -0,0 +1,55 @@ +package base + +import ( + "net" + "strings" + "testing" +) + +func TestParseVCSUrl(t *testing.T) { + repos := []string{ + // ssh://[user@]host.xz[:port]/path/to/repo.git/ + "ssh://git@github.com:7875/go-kratos/kratos.git", + // git://host.xz[:port]/path/to/repo.git/ + "git://github.com:7875/go-kratos/kratos.git", + // http[s]://host.xz[:port]/path/to/repo.git/ + "https://github.com:7875/go-kratos/kratos.git", + // ftp[s]://host.xz[:port]/path/to/repo.git/ + "ftps://github.com:7875/go-kratos/kratos.git", + //[user@]host.xz:path/to/repo.git/ + "git@github.com:go-kratos/kratos.git", + // ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/ + "ssh://git@github.com:7875/go-kratos/kratos.git", + // git://host.xz[:port]/~[user]/path/to/repo.git/ + "git://github.com:7875/go-kratos/kratos.git", + //[user@]host.xz:/~[user]/path/to/repo.git/ + "git@github.com:go-kratos/kratos.git", + ///path/to/repo.git/ + "~/go-kratos/kratos.git", + // file:///path/to/repo.git/ + "file://~/go-kratos/kratos.git", + } + for _, repo := range repos { + url, err := ParseVCSUrl(repo) + if err != nil { + t.Fatal(repo, err) + } + urlPath := strings.TrimLeft(url.Path, "/") + if urlPath != "go-kratos/kratos.git" { + t.Fatal(repo, "parse url failed", urlPath) + } + } +} + +func TestParseSsh(t *testing.T) { + repo := "ssh://git@github.com:7875/go-kratos/kratos.git" + url, err := ParseVCSUrl(repo) + if err != nil { + t.Fatal(err) + } + host, _, err := net.SplitHostPort(url.Host) + if err != nil { + host = url.Host + } + t.Log(host, url.Path) +} From cbfb6db9cf68df3919049f6220096adf83c982e6 Mon Sep 17 00:00:00 2001 From: icylight <408209435@qq.com> Date: Wed, 31 Aug 2022 21:35:59 +0800 Subject: [PATCH 05/46] fix(internal/host): Extract can't return the minium index ip (#2298) * fix(internal/host): Extract can't return the minium index ip * rollback * fix index --- internal/host/host.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/internal/host/host.go b/internal/host/host.go index d5cc7ffa3..bf204eede 100644 --- a/internal/host/host.go +++ b/internal/host/host.go @@ -50,16 +50,13 @@ func Extract(hostPort string, lis net.Listener) (string, error) { if err != nil { return "", err } - lowest := int(^uint(0) >> 1) + minIndex := int(^uint(0) >> 1) var result net.IP for _, iface := range ifaces { if (iface.Flags & net.FlagUp) == 0 { continue } - if iface.Index < lowest || result == nil { - lowest = iface.Index - } - if result != nil { + if iface.Index >= minIndex && result != nil { continue } addrs, err := iface.Addrs() @@ -77,7 +74,9 @@ func Extract(hostPort string, lis net.Listener) (string, error) { continue } if isValidIP(ip.String()) { + minIndex = iface.Index result = ip + break } } } From ad7597c0b167a849d3d424ca4ac41b3004f633d7 Mon Sep 17 00:00:00 2001 From: Wang-TaoTao <53828914+Wang-TaoTao@users.noreply.github.com> Date: Wed, 31 Aug 2022 21:42:54 +0800 Subject: [PATCH 06/46] fix: init global selector to wrr (#2323) --- transport/grpc/client.go | 4 ++-- transport/http/client.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/transport/grpc/client.go b/transport/grpc/client.go index a1424d209..da6ceb028 100644 --- a/transport/grpc/client.go +++ b/transport/grpc/client.go @@ -10,7 +10,7 @@ import ( "github.com/go-kratos/kratos/v2/middleware" "github.com/go-kratos/kratos/v2/registry" "github.com/go-kratos/kratos/v2/selector" - "github.com/go-kratos/kratos/v2/selector/p2c" + "github.com/go-kratos/kratos/v2/selector/wrr" "github.com/go-kratos/kratos/v2/transport" "github.com/go-kratos/kratos/v2/transport/grpc/resolver/discovery" @@ -25,7 +25,7 @@ import ( func init() { if selector.GlobalSelector() == nil { - selector.SetGlobalSelector(p2c.NewBuilder()) + selector.SetGlobalSelector(wrr.NewBuilder()) } } diff --git a/transport/http/client.go b/transport/http/client.go index 79ac4f911..c0ad5ee38 100644 --- a/transport/http/client.go +++ b/transport/http/client.go @@ -16,13 +16,13 @@ import ( "github.com/go-kratos/kratos/v2/middleware" "github.com/go-kratos/kratos/v2/registry" "github.com/go-kratos/kratos/v2/selector" - "github.com/go-kratos/kratos/v2/selector/p2c" + "github.com/go-kratos/kratos/v2/selector/wrr" "github.com/go-kratos/kratos/v2/transport" ) func init() { if selector.GlobalSelector() == nil { - selector.SetGlobalSelector(p2c.NewBuilder()) + selector.SetGlobalSelector(wrr.NewBuilder()) } } From 60b00c8ade032c18b1bba9c9a96a84db4a574bae Mon Sep 17 00:00:00 2001 From: icylight <408209435@qq.com> Date: Wed, 31 Aug 2022 22:58:32 +0800 Subject: [PATCH 07/46] fix(config/env): prefixs typo (#2321) --- config/env/env.go | 10 +++++----- config/env/env_test.go | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/config/env/env.go b/config/env/env.go index 6c104f1c1..30e011b92 100644 --- a/config/env/env.go +++ b/config/env/env.go @@ -8,11 +8,11 @@ import ( ) type env struct { - prefixs []string + prefixes []string } -func NewSource(prefixs ...string) config.Source { - return &env{prefixs: prefixs} +func NewSource(prefixes ...string) config.Source { + return &env{prefixes: prefixes} } func (e *env) Load() (kv []*config.KeyValue, err error) { @@ -29,8 +29,8 @@ func (e *env) load(envStrings []string) []*config.KeyValue { v = subs[1] } - if len(e.prefixs) > 0 { - p, ok := matchPrefix(e.prefixs, k) + if len(e.prefixes) > 0 { + p, ok := matchPrefix(e.prefixes, k) if !ok || len(p) == len(k) { continue } diff --git a/config/env/env_test.go b/config/env/env_test.go index 6574c1d83..72fcff31d 100644 --- a/config/env/env_test.go +++ b/config/env/env_test.go @@ -261,7 +261,7 @@ func TestEnvWithoutPrefix(t *testing.T) { func Test_env_load(t *testing.T) { type fields struct { - prefixs []string + prefixes []string } type args struct { envStrings []string @@ -275,7 +275,7 @@ func Test_env_load(t *testing.T) { { name: "without prefixes", fields: fields{ - prefixs: nil, + prefixes: nil, }, args: args{ envStrings: []string{ @@ -294,7 +294,7 @@ func Test_env_load(t *testing.T) { { name: "empty prefix", fields: fields{ - prefixs: []string{""}, + prefixes: []string{""}, }, args: args{ envStrings: []string{ @@ -313,7 +313,7 @@ func Test_env_load(t *testing.T) { { name: "underscore prefix", fields: fields{ - prefixs: []string{"_"}, + prefixes: []string{"_"}, }, args: args{ envStrings: []string{ @@ -332,7 +332,7 @@ func Test_env_load(t *testing.T) { { name: "with prefixes", fields: fields{ - prefixs: []string{"KRATOS_", "FOO"}, + prefixes: []string{"KRATOS_", "FOO"}, }, args: args{ envStrings: []string{ @@ -351,7 +351,7 @@ func Test_env_load(t *testing.T) { { name: "should not panic #1", fields: fields{ - prefixs: []string{"FOO"}, + prefixes: []string{"FOO"}, }, args: args{ envStrings: []string{ @@ -364,7 +364,7 @@ func Test_env_load(t *testing.T) { { name: "should not panic #2", fields: fields{ - prefixs: []string{"FOO=1"}, + prefixes: []string{"FOO=1"}, }, args: args{ envStrings: []string{ @@ -377,7 +377,7 @@ func Test_env_load(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { e := &env{ - prefixs: tt.fields.prefixs, + prefixes: tt.fields.prefixes, } got := e.load(tt.args.envStrings) if !reflect.DeepEqual(tt.want, got) { @@ -419,8 +419,8 @@ func Test_matchPrefix(t *testing.T) { } func Test_env_watch(t *testing.T) { - prefixs := []string{"BAR", "FOO"} - source := NewSource(prefixs...) + prefixes := []string{"BAR", "FOO"} + source := NewSource(prefixes...) w, err := source.Watch() if err != nil { t.Errorf("expect no err, got %v", err) From 503efd38251825d49d6114881ec461251bcb5033 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Sep 2022 16:09:21 +0800 Subject: [PATCH 08/46] build(deps): bump go.uber.org/zap in /contrib/log/zap (#2326) Bumps [go.uber.org/zap](https://github.com/uber-go/zap) from 1.22.0 to 1.23.0. - [Release notes](https://github.com/uber-go/zap/releases) - [Changelog](https://github.com/uber-go/zap/blob/master/CHANGELOG.md) - [Commits](https://github.com/uber-go/zap/compare/v1.22.0...v1.23.0) --- updated-dependencies: - dependency-name: go.uber.org/zap dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- contrib/log/zap/go.mod | 2 +- contrib/log/zap/go.sum | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/contrib/log/zap/go.mod b/contrib/log/zap/go.mod index 192127ee0..0a8e74f60 100644 --- a/contrib/log/zap/go.mod +++ b/contrib/log/zap/go.mod @@ -4,7 +4,7 @@ go 1.16 require ( github.com/go-kratos/kratos/v2 v2.5.0 - go.uber.org/zap v1.22.0 + go.uber.org/zap v1.23.0 ) replace github.com/go-kratos/kratos/v2 => ../../../ diff --git a/contrib/log/zap/go.sum b/contrib/log/zap/go.sum index 1a82a3847..5c9de790a 100644 --- a/contrib/log/zap/go.sum +++ b/contrib/log/zap/go.sum @@ -72,11 +72,13 @@ github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1: github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/shirou/gopsutil/v3 v3.21.8/go.mod h1:YWp/H8Qs5fVmf17v7JNZzA0mPJ+mS2e9JdiUF9LlKzQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs= github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= @@ -90,8 +92,8 @@ go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/zap v1.22.0 h1:Zcye5DUgBloQ9BaT4qc9BnjOFog5TvBSAGkJ3Nf70c0= -go.uber.org/zap v1.22.0/go.mod h1:H4siCOZOrAolnUPJEkfaSjDqyP+BDS0DdDWzwcgt3+U= +go.uber.org/zap v1.23.0 h1:OjGQ5KQDEUawVHxNwQgPpiypGHOxo2mNZsOqTak4fFY= +go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= From 7a336ca353ab7b899ad4e09841544b8962cf6bee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Sep 2022 16:10:55 +0800 Subject: [PATCH 09/46] build(deps): bump google.golang.org/protobuf in /contrib/opensergo (#2248) Bumps [google.golang.org/protobuf](https://github.com/protocolbuffers/protobuf-go) from 1.28.0 to 1.28.1. - [Release notes](https://github.com/protocolbuffers/protobuf-go/releases) - [Changelog](https://github.com/protocolbuffers/protobuf-go/blob/master/release.bash) - [Commits](https://github.com/protocolbuffers/protobuf-go/compare/v1.28.0...v1.28.1) --- updated-dependencies: - dependency-name: google.golang.org/protobuf dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- contrib/opensergo/go.mod | 2 +- contrib/opensergo/go.sum | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/contrib/opensergo/go.mod b/contrib/opensergo/go.mod index beba8f7f9..0b920de4b 100644 --- a/contrib/opensergo/go.mod +++ b/contrib/opensergo/go.mod @@ -8,7 +8,7 @@ require ( golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2 google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd google.golang.org/grpc v1.46.2 - google.golang.org/protobuf v1.28.0 + google.golang.org/protobuf v1.28.1 ) require ( diff --git a/contrib/opensergo/go.sum b/contrib/opensergo/go.sum index f894f6ff2..aa486a6fe 100644 --- a/contrib/opensergo/go.sum +++ b/contrib/opensergo/go.sum @@ -167,8 +167,9 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From aaabd0747484a8b1c654db3dd6fe3c02cd699d15 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Sep 2022 16:12:08 +0800 Subject: [PATCH 10/46] build(deps): bump actions/setup-go from 3.2.1 to 3.3.0 (#2313) Bumps [actions/setup-go](https://github.com/actions/setup-go) from 3.2.1 to 3.3.0. - [Release notes](https://github.com/actions/setup-go/releases) - [Commits](https://github.com/actions/setup-go/compare/v3.2.1...v3.3.0) --- updated-dependencies: - dependency-name: actions/setup-go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index b1c2ca11a..552fef4a9 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -44,7 +44,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Set up Go - uses: actions/setup-go@v3.2.1 + uses: actions/setup-go@v3.3.0 with: go-version: ${{ matrix.go }} From e820b392e99c6f99e9471530008a4e27ba93a4e4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 1 Sep 2022 21:14:50 +0800 Subject: [PATCH 11/46] build(deps): bump github.com/hashicorp/consul/api (#2279) Bumps [github.com/hashicorp/consul/api](https://github.com/hashicorp/consul) from 1.13.1 to 1.14.0. - [Release notes](https://github.com/hashicorp/consul/releases) - [Changelog](https://github.com/hashicorp/consul/blob/main/CHANGELOG.md) - [Commits](https://github.com/hashicorp/consul/compare/v1.13.1...api/v1.14.0) --- updated-dependencies: - dependency-name: github.com/hashicorp/consul/api dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- contrib/config/consul/go.mod | 2 +- contrib/config/consul/go.sum | 125 +++++++++++++++++++++++++++++------ 2 files changed, 104 insertions(+), 23 deletions(-) diff --git a/contrib/config/consul/go.mod b/contrib/config/consul/go.mod index a251affb3..49e23b744 100644 --- a/contrib/config/consul/go.mod +++ b/contrib/config/consul/go.mod @@ -4,7 +4,7 @@ go 1.15 require ( github.com/go-kratos/kratos/v2 v2.4.0 - github.com/hashicorp/consul/api v1.13.1 + github.com/hashicorp/consul/api v1.14.0 ) replace github.com/go-kratos/kratos/v2 => ../../../ diff --git a/contrib/config/consul/go.sum b/contrib/config/consul/go.sum index 5816b336c..25fbdf7f3 100644 --- a/contrib/config/consul/go.sum +++ b/contrib/config/consul/go.sum @@ -1,16 +1,27 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da h1:8GUt8eRujhVEGZFFEjBj46YV4rDjvGrNxb0KMWYkL2I= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-metrics v0.3.10 h1:FR+drcQStOe+32sYyJYyZ7FIdgoGGBnwLl+flodp8Uo= +github.com/armon/go-metrics v0.3.10/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= +github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= @@ -18,6 +29,7 @@ github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XP github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -32,17 +44,24 @@ github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kratos/aegis v0.1.2/go.mod h1:jYeSQ3Gesba478zEnujOiG5QdsyF3Xk/8owFUeKcHxw= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/form/v4 v4.2.0/go.mod h1:q1a2BY+AQUUzhl6xA/6hBetay6dEIhMHjgvJiGo6K7U= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang-jwt/jwt/v4 v4.4.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= @@ -55,8 +74,9 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c h1:964Od4U6p2jUkFxvCydnIczKteheJEzHRToSGK3Bnlw= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -66,50 +86,69 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/hashicorp/consul/api v1.13.1 h1:r5cPdVFUy+pFF7nt+0ArLD9hm+E39OewJkvNdjKXcL4= -github.com/hashicorp/consul/api v1.13.1/go.mod h1:+1VcOos0TVdQFqXxphG4zmGcwQB4KVGkp1maPqnkDpE= +github.com/hashicorp/consul/api v1.14.0 h1:Y64GIJ8hYTu+tuGekwO4G4ardXoiCivX9wv1iP/kihk= +github.com/hashicorp/consul/api v1.14.0/go.mod h1:bcaw5CSZ7NE9qfOfKCI1xb7ZKjzu/MyvQkCLTfqLqxQ= github.com/hashicorp/consul/sdk v0.10.0 h1:rGLEh2AWK4K0KCMvqWAz2EYxQqgciIfMagWZ0nVe5MI= github.com/hashicorp/consul/sdk v0.10.0/go.mod h1:yPkX5Q6CsxTFMjQQDJwzeNmUUF5NUGGbrDsv9wTb8cw= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-hclog v0.12.0 h1:d4QkX8FRTYaKaCZBoXYY8zJX2BXjWxurN/GA2tkrmZM= github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-immutable-radix v1.0.0 h1:AKDB1HM5PWEA7i4nhcpwOrO2byshxBjXVn/J/3+z5/0= +github.com/hashicorp/go-hclog v0.14.1 h1:nQcJDQwIAGnmoUWp8ubocEX40cCml/17YkF6csQLReU= +github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-msgpack v0.5.3 h1:zKjpN5BK/P5lMYrLmBHdBULWbJ0XpYR+7NGzqkZzoD4= +github.com/hashicorp/go-immutable-radix v1.3.0 h1:8exGP7ego3OmkfksihtSouGMZ+hQrhxx+FVELeXpVPE= +github.com/hashicorp/go-immutable-radix v1.3.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-msgpack v0.5.5 h1:i9R9JSrqIz0QVLz3sz+i3YJdT7TTSLcfLLzJi9aZTuI= +github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= -github.com/hashicorp/go-multierror v1.1.0 h1:B9UzwGQJehnUY1yNrnwREHc3fGbC2xefo8g4TbElacI= github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= +github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= +github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= +github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc= github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= -github.com/hashicorp/go-sockaddr v1.0.0 h1:GeH6tui99pF4NJgfnhp+L6+FfobzVW3Ah46sLo0ICXs= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-sockaddr v1.0.2 h1:ztczhD1jLxIRjVejw8gFomI1BQZOe2WoVOu0SyteCQc= +github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/golang-lru v0.5.0 h1:CL2msUPvZTLb5O648aiLNJw3hnBxN2+1Jq8rCOH9wdo= +github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= +github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= +github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= -github.com/hashicorp/memberlist v0.3.0 h1:8+567mCcFDnS5ADl7lrpxPMWiFCElyUEeW0gtj34fMA= github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= -github.com/hashicorp/serf v0.9.6 h1:uuEX1kLR6aoda1TBttmJQKDLZE1Ob7KN0NPdE7EtCDc= -github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= +github.com/hashicorp/memberlist v0.3.1 h1:MXgUXLqva1QvpVEDQW1IQLG0wivQAtmFlHRQ+1vWZfM= +github.com/hashicorp/memberlist v0.3.1/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= +github.com/hashicorp/serf v0.9.7 h1:hkdgbqizGQHuU5IPqYM1JdSMV8nKfpuOnZYXssk9muY= +github.com/hashicorp/serf v0.9.7/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= -github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE= @@ -120,32 +159,59 @@ github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcME github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.41 h1:WMszZWJG0XmzbK9FEmzH2TVcqYzFesusSIB41b8KHxY= github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= +github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c h1:Lgl0gzECD8GnQ5QCWA8o6BtfL6mDH5rQgM4/fX3avOs= +github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= +github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= +github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= +github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/shirou/gopsutil/v3 v3.21.8/go.mod h1:YWp/H8Qs5fVmf17v7JNZzA0mPJ+mS2e9JdiUF9LlKzQ= -github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= @@ -153,10 +219,12 @@ github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMT github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs= github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8= +github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= go.opentelemetry.io/otel v1.7.0/go.mod h1:5BdUoMIz5WEs0vt0CUEMtSSaTSHBBVwrhnz7+nrD5xk= go.opentelemetry.io/otel/sdk v1.7.0/go.mod h1:uTEOTwaqIVuTGiJN7ii13Ibp75wJmYUDe374q6cZwUU= go.opentelemetry.io/otel/trace v1.7.0/go.mod h1:fzLSB9nqR2eXzxPXb2JW9IKE+ScyXA48yyE4TNvoHqU= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -166,38 +234,46 @@ golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvx golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1 h1:4qWs8cYYH6PoEFy4dfhDFgoMGkwAcETd+MmPdCPMzUc= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= +golang.org/x/net v0.0.0-20211216030914-fe4d6282115f h1:hEYJvxw1lSnWIl8X9ofsYMklzaDs90JI2az5YMd4fPM= +golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 h1:w8s32wxx3sY+OjLlv9qltkLU5yvJzxjjgiHWLjdIcw4= golang.org/x/sync v0.0.0-20220513210516-0976fa681c29/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -205,6 +281,7 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -255,11 +332,15 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From 39536d32795fa7bda4fdd4e369c63b9d5e3d3a2a Mon Sep 17 00:00:00 2001 From: 180909 <734461790@qq.com> Date: Thu, 1 Sep 2022 23:21:27 +0800 Subject: [PATCH 12/46] fix(cmd): fix CmdAdd long message example (#2343) --- cmd/kratos/internal/proto/add/add.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/kratos/internal/proto/add/add.go b/cmd/kratos/internal/proto/add/add.go index 626b5db25..88433dc75 100644 --- a/cmd/kratos/internal/proto/add/add.go +++ b/cmd/kratos/internal/proto/add/add.go @@ -15,7 +15,7 @@ import ( var CmdAdd = &cobra.Command{ Use: "add", Short: "Add a proto API template", - Long: "Add a proto API template. Example: kratos add helloworld/v1/hello.proto", + Long: "Add a proto API template. Example: kratos proto add helloworld/v1/hello.proto", Run: run, } From 617ee1aa39a09f1b93ce246d7a569e30605690fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E4=BB=B2=E8=BE=89?= Date: Fri, 2 Sep 2022 15:08:26 +0800 Subject: [PATCH 13/46] fix(lint): Using deprecated package `io/ioutil` cause lint interrupted, change to `os` or `io` package. (#2353) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 黄仲辉 <610195979@qq.com> --- contrib/config/polaris/config_test.go | 4 ++-- contrib/opensergo/opensergo.go | 5 ++--- contrib/opensergo/opensergo_test.go | 3 +-- contrib/registry/eureka/client.go | 5 ++--- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/contrib/config/polaris/config_test.go b/contrib/config/polaris/config_test.go index fc864526c..bf8b6fd61 100644 --- a/contrib/config/polaris/config_test.go +++ b/contrib/config/polaris/config_test.go @@ -4,7 +4,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "reflect" "strings" @@ -38,7 +38,7 @@ func makeJSONRequest(uri string, data string, method string, headers map[string] return nil, err } defer res.Body.Close() - return ioutil.ReadAll(res.Body) + return io.ReadAll(res.Body) } type commonRes struct { diff --git a/contrib/opensergo/opensergo.go b/contrib/opensergo/opensergo.go index 6da1f5962..112c0babe 100644 --- a/contrib/opensergo/opensergo.go +++ b/contrib/opensergo/opensergo.go @@ -2,7 +2,6 @@ package opensergo import ( "encoding/json" - "io/ioutil" "net" "net/url" "os" @@ -52,7 +51,7 @@ func New(opts ...Option) (*OpenSergo, error) { } } if v := os.Getenv("OPENSERGO_BOOTSTRAP_CONFIG"); v != "" { - b, err := ioutil.ReadFile(v) + b, err := os.ReadFile(v) if err != nil { return nil, err } @@ -89,7 +88,7 @@ func (s *OpenSergo) ReportMetadata(ctx context.Context, app kratos.AppInfo) erro } for _, endpoint := range app.Endpoint() { - u, err := url.Parse(endpoint) //nolint + u, err := url.Parse(endpoint) // nolint if err != nil { return err } diff --git a/contrib/opensergo/opensergo_test.go b/contrib/opensergo/opensergo_test.go index 5c752d1c1..9f49bbeef 100644 --- a/contrib/opensergo/opensergo_test.go +++ b/contrib/opensergo/opensergo_test.go @@ -1,7 +1,6 @@ package opensergo import ( - "io/ioutil" "net" "os" "path/filepath" @@ -337,7 +336,7 @@ func TestOpenSergo(t *testing.T) { }, preFunc: func(t *testing.T) { fileContent := `{"endpoint": "127.0.0.1:9090"}` - err := ioutil.WriteFile("test.json", []byte(fileContent), 0o644) + err := os.WriteFile("test.json", []byte(fileContent), 0o644) if err != nil { t.Fatalf("ioutil.WriteFile error:%s", err) } diff --git a/contrib/registry/eureka/client.go b/contrib/registry/eureka/client.go index 64cdddec9..35dd14729 100644 --- a/contrib/registry/eureka/client.go +++ b/contrib/registry/eureka/client.go @@ -6,7 +6,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "math/rand" "net/http" "strings" @@ -323,12 +322,12 @@ func (e *Client) do(ctx context.Context, method string, params []string, input i continue } defer func() { - _, _ = io.Copy(ioutil.Discard, resp.Body) + _, _ = io.Copy(io.Discard, resp.Body) resp.Body.Close() }() if output != nil && resp.StatusCode/100 == 2 { - data, err := ioutil.ReadAll(resp.Body) + data, err := io.ReadAll(resp.Body) if err != nil { return err } From cb69bf3714373555c6c1db6424312b1bf19f7373 Mon Sep 17 00:00:00 2001 From: GongGuoWei <62499904+guowei-gong@users.noreply.github.com> Date: Tue, 6 Sep 2022 13:46:14 +0800 Subject: [PATCH 14/46] test(config): add etcd config method test (#2349) Added test cases for the about etcd method - WithPath(path string) - WithPrefix(prefix bool) Update #2135 --- contrib/config/etcd/config_test.go | 61 +++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/contrib/config/etcd/config_test.go b/contrib/config/etcd/config_test.go index c106c0573..821167ec4 100644 --- a/contrib/config/etcd/config_test.go +++ b/contrib/config/etcd/config_test.go @@ -15,7 +15,8 @@ const testKey = "/kratos/test/config" func TestConfig(t *testing.T) { client, err := clientv3.New(clientv3.Config{ Endpoints: []string{"127.0.0.1:2379"}, - DialTimeout: time.Second, DialOptions: []grpc.DialOption{grpc.WithBlock()}, + DialTimeout: time.Second, + DialOptions: []grpc.DialOption{grpc.WithBlock()}, }) if err != nil { t.Fatal(err) @@ -108,3 +109,61 @@ func TestExtToFormat(t *testing.T) { t.Errorf("kvs[0].Format is %s", kvs[0].Format) } } + +func TestEtcdWithPath(t *testing.T) { + tests := []struct { + name string + fields string + want string + }{ + { + name: "default", + fields: testKey, + want: testKey, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + options := &options{ + ctx: context.Background(), + } + + got := WithPath(tt.fields) + got(options) + + if options.path != tt.want { + t.Errorf("WithPath(tt.fields) = %v, want %v", got, tt.want) + } + }) + } +} + +func TestEtcdWithPrefix(t *testing.T) { + tests := []struct { + name string + fields bool + want bool + }{ + { + name: "default", + fields: false, + want: false, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + options := &options{ + ctx: context.Background(), + } + + got := WithPrefix(tt.fields) + got(options) + + if options.prefix != tt.want { + t.Errorf("WithPrefix(tt.fields) = %v, want %v", got, tt.want) + } + }) + } +} From 8d76eebf8bbeefe0e14a521077371cb695c0b9db Mon Sep 17 00:00:00 2001 From: 180909 <734461790@qq.com> Date: Tue, 6 Sep 2022 13:49:16 +0800 Subject: [PATCH 15/46] test(cmd/change): add ParseGithubURL test (#2339) * test(cmd/change): add ParseGithubURL test * use anonymous struct --- cmd/kratos/internal/change/get_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 cmd/kratos/internal/change/get_test.go diff --git a/cmd/kratos/internal/change/get_test.go b/cmd/kratos/internal/change/get_test.go new file mode 100644 index 000000000..a6a9d037a --- /dev/null +++ b/cmd/kratos/internal/change/get_test.go @@ -0,0 +1,25 @@ +package change + +import "testing" + +func TestParseGithubURL(t *testing.T) { + urls := []struct { + url string + owner string + repo string + }{ + {"https://github.com/go-kratos/kratos.git", "go-kratos", "kratos"}, + {"https://github.com/go-kratos/kratos", "go-kratos", "kratos"}, + {"git@github.com:go-kratos/kratos.git", "go-kratos", "kratos"}, + {"https://github.com/go-kratos/go-kratos.dev.git", "go-kratos", "go-kratos.dev"}, + } + for _, url := range urls { + owner, repo := ParseGithubURL(url.url) + if owner != url.owner { + t.Fatalf("owner want: %s, got: %s", owner, url.owner) + } + if repo != url.repo { + t.Fatalf("repo want: %s, got: %s", repo, url.repo) + } + } +} From 18c57349301035046cad6df216e300d09c3a2780 Mon Sep 17 00:00:00 2001 From: 180909 <734461790@qq.com> Date: Tue, 6 Sep 2022 13:50:00 +0800 Subject: [PATCH 16/46] test(cmd): add ModulePath test (#2337) --- cmd/kratos/internal/base/mod_test.go | 34 +++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/cmd/kratos/internal/base/mod_test.go b/cmd/kratos/internal/base/mod_test.go index 9ce7e3ccb..577896b03 100644 --- a/cmd/kratos/internal/base/mod_test.go +++ b/cmd/kratos/internal/base/mod_test.go @@ -1,6 +1,9 @@ package base -import "testing" +import ( + "os" + "testing" +) func TestModuleVersion(t *testing.T) { v, err := ModuleVersion("golang.org/x/mod") @@ -9,3 +12,32 @@ func TestModuleVersion(t *testing.T) { } t.Log(v) } + +func TestModulePath(t *testing.T) { + if err := os.Mkdir("/tmp/test_mod", os.ModePerm); err != nil { + t.Fatal(err) + } + + defer os.RemoveAll("/tmp/test_mod") + + f, err := os.Create("/tmp/test_mod/go.mod") + if err != nil { + t.Fatal(err) + } + + mod := `module github.com/go-kratos/kratos/v2 + +go 1.16` + _, err = f.WriteString(mod) + if err != nil { + t.Fatal(err) + } + + p, err := ModulePath("/tmp/test_mod/go.mod") + if err != nil { + t.Fatal(err) + } + if p != "github.com/go-kratos/kratos/v2" { + t.Fatalf("want: %s, got: %s", "module github.com/go-kratos/kratos/v2", p) + } +} From 0f0c75e20b5dfb3f613b9a12391277c98509b3ec Mon Sep 17 00:00:00 2001 From: 180909 <734461790@qq.com> Date: Wed, 7 Sep 2022 11:42:59 +0800 Subject: [PATCH 17/46] feat(cmd): user prePage to check changelog dev (#2340) --- cmd/kratos/internal/change/get.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/kratos/internal/change/get.go b/cmd/kratos/internal/change/get.go index e91de81bc..18e02072a 100644 --- a/cmd/kratos/internal/change/get.go +++ b/cmd/kratos/internal/change/get.go @@ -59,9 +59,10 @@ func (g *GithubAPI) GetReleaseInfo(version string) ReleaseInfo { func (g *GithubAPI) GetCommitsInfo() []CommitInfo { info := g.GetReleaseInfo("latest") page := 1 + prePage := 100 var list []CommitInfo for { - url := fmt.Sprintf("https://api.github.com/repos/%s/%s/commits?pre_page=100&page=%d&since=%s", g.Owner, g.Repo, page, info.PublishedAt) + url := fmt.Sprintf("https://api.github.com/repos/%s/%s/commits?pre_page=%d&page=%d&since=%s", g.Owner, g.Repo, prePage, page, info.PublishedAt) resp, code := requestGithubAPI(url, "GET", nil, g.Token) if code != http.StatusOK { printGithubErrorInfo(resp) @@ -72,7 +73,7 @@ func (g *GithubAPI) GetCommitsInfo() []CommitInfo { fatal(err) } list = append(list, res...) - if len(res) < http.StatusContinue { + if len(res) < prePage { break } page++ From e176ddfcdd29b5881fd23a9394c52dec002d27d6 Mon Sep 17 00:00:00 2001 From: hshe Date: Wed, 7 Sep 2022 11:43:55 +0800 Subject: [PATCH 18/46] feat(internal/host): prefer ipv4 than ipv6 (#2342) * feat:prefer ipv4 than ipv6 * feat:prefer ipv4 than ipv6 * feat:prefer ipv4 than ipv6 * feat:prefer ipv4 than ipv6 --- internal/host/host.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/internal/host/host.go b/internal/host/host.go index bf204eede..774f7ae37 100644 --- a/internal/host/host.go +++ b/internal/host/host.go @@ -51,19 +51,19 @@ func Extract(hostPort string, lis net.Listener) (string, error) { return "", err } minIndex := int(^uint(0) >> 1) - var result net.IP + ips := make([]net.IP, 0) for _, iface := range ifaces { if (iface.Flags & net.FlagUp) == 0 { continue } - if iface.Index >= minIndex && result != nil { + if iface.Index >= minIndex && len(ips) != 0 { continue } addrs, err := iface.Addrs() if err != nil { continue } - for _, rawAddr := range addrs { + for i, rawAddr := range addrs { var ip net.IP switch addr := rawAddr.(type) { case *net.IPAddr: @@ -75,13 +75,18 @@ func Extract(hostPort string, lis net.Listener) (string, error) { } if isValidIP(ip.String()) { minIndex = iface.Index - result = ip - break + if i == 0 { + ips = make([]net.IP, 0, 1) + } + ips = append(ips, ip) + if ip.To4() != nil { + break + } } } } - if result != nil { - return net.JoinHostPort(result.String(), port), nil + if len(ips) != 0 { + return net.JoinHostPort(ips[len(ips)-1].String(), port), nil } return "", nil } From 667d63839c3924191497128afec9551212218d4a Mon Sep 17 00:00:00 2001 From: Guoqiang Ding Date: Wed, 7 Sep 2022 11:44:23 +0800 Subject: [PATCH 19/46] fix(makefile): add "make proto" for proto generating (#2130) Co-authored-by: Guoqiang Ding --- Makefile | 7 ++++++- api/metadata/server.go | 3 --- errors/errors.go | 2 -- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 842c95625..843fceb41 100644 --- a/Makefile +++ b/Makefile @@ -76,4 +76,9 @@ test-coverage: .PHONY: lint lint: $(LINTER) @${TOOLS_SHELL} lint - @echo "lint check finished" \ No newline at end of file + @echo "lint check finished" + +.PHONY: proto +proto: + protoc --proto_path=./api --proto_path=./third_party --go_out=paths=source_relative:./api --go-grpc_out=paths=source_relative:./api --go-http_out=paths=source_relative:./api metadata/metadata.proto + protoc --proto_path=./third_party --go_out=paths=source_relative:./ errors/errors.proto diff --git a/api/metadata/server.go b/api/metadata/server.go index 50f90f61e..96f0e1e67 100644 --- a/api/metadata/server.go +++ b/api/metadata/server.go @@ -20,9 +20,6 @@ import ( dpb "google.golang.org/protobuf/types/descriptorpb" ) -//nolint:lll -//go:generate protoc --proto_path=. --proto_path=../../third_party --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. --go-http_out=paths=source_relative:. metadata.proto - // Server is api meta server type Server struct { UnimplementedMetadataServer diff --git a/errors/errors.go b/errors/errors.go index e6bebbf8b..fd95ff3b7 100644 --- a/errors/errors.go +++ b/errors/errors.go @@ -9,8 +9,6 @@ import ( "google.golang.org/grpc/status" ) -//go:generate protoc -I. --go_out=paths=source_relative:. errors.proto - const ( // UnknownCode is unknown code for error info. UnknownCode = 500 From ae505063fe3aa4392e6eb8889cfd44feaf95f9ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=85=E5=AD=90?= Date: Wed, 14 Sep 2022 19:44:04 +0800 Subject: [PATCH 20/46] fix(apollo): config return nil when watch err --- contrib/config/apollo/watcher.go | 1 + 1 file changed, 1 insertion(+) diff --git a/contrib/config/apollo/watcher.go b/contrib/config/apollo/watcher.go index 670139a26..94ef2ef0b 100644 --- a/contrib/config/apollo/watcher.go +++ b/contrib/config/apollo/watcher.go @@ -31,6 +31,7 @@ func (c *customChangeListener) onChange(namespace string, changes map[string]*st value, err := c.apollo.client.GetConfigCache(namespace).Get("content") if err != nil { log.Warnw("apollo get config failed", "err", err) + return nil } kv = append(kv, &config.KeyValue{ Key: namespace, From f2a33929d0bb3364fe02352689b1b5c79fa6f66f Mon Sep 17 00:00:00 2001 From: "jesse.tang" <1430482733@qq.com> Date: Wed, 14 Sep 2022 22:05:48 +0800 Subject: [PATCH 21/46] fix: modify interface check way (#2375) * fix: modify interface check way * fix --- contrib/registry/etcd/watcher.go | 2 +- contrib/registry/eureka/client.go | 2 +- contrib/registry/eureka/watcher.go | 2 +- contrib/registry/zookeeper/watcher.go | 2 +- middleware/logging/logging_test.go | 2 +- middleware/selector/selector_test.go | 2 +- middleware/tracing/tracing_test.go | 2 +- selector/p2c/p2c.go | 2 +- selector/random/random.go | 2 +- selector/wrr/wrr.go | 2 +- transport/grpc/transport.go | 2 +- transport/http/transport.go | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/contrib/registry/etcd/watcher.go b/contrib/registry/etcd/watcher.go index 22e63474c..a5bf63c41 100644 --- a/contrib/registry/etcd/watcher.go +++ b/contrib/registry/etcd/watcher.go @@ -7,7 +7,7 @@ import ( clientv3 "go.etcd.io/etcd/client/v3" ) -var _ registry.Watcher = &watcher{} +var _ registry.Watcher = (*watcher)(nil) type watcher struct { key string diff --git a/contrib/registry/eureka/client.go b/contrib/registry/eureka/client.go index 35dd14729..f2b4e96f3 100644 --- a/contrib/registry/eureka/client.go +++ b/contrib/registry/eureka/client.go @@ -82,7 +82,7 @@ type DataCenterInfo struct { Class string `json:"@class"` } -var _ APIInterface = new(Client) +var _ APIInterface = (*Client)(nil) type APIInterface interface { Register(ctx context.Context, ep Endpoint) error diff --git a/contrib/registry/eureka/watcher.go b/contrib/registry/eureka/watcher.go index 468d97b24..de37d3229 100644 --- a/contrib/registry/eureka/watcher.go +++ b/contrib/registry/eureka/watcher.go @@ -6,7 +6,7 @@ import ( "github.com/go-kratos/kratos/v2/registry" ) -var _ registry.Watcher = &watcher{} +var _ registry.Watcher = (*watcher)(nil) type watcher struct { ctx context.Context diff --git a/contrib/registry/zookeeper/watcher.go b/contrib/registry/zookeeper/watcher.go index 76f502fa8..f20096754 100644 --- a/contrib/registry/zookeeper/watcher.go +++ b/contrib/registry/zookeeper/watcher.go @@ -10,7 +10,7 @@ import ( "github.com/go-zookeeper/zk" ) -var _ registry.Watcher = &watcher{} +var _ registry.Watcher = (*watcher)(nil) var ErrWatcherStopped = errors.New("watcher stopped") diff --git a/middleware/logging/logging_test.go b/middleware/logging/logging_test.go index 7242f8e04..6ad1a02c9 100644 --- a/middleware/logging/logging_test.go +++ b/middleware/logging/logging_test.go @@ -11,7 +11,7 @@ import ( "github.com/go-kratos/kratos/v2/transport" ) -var _ transport.Transporter = &Transport{} +var _ transport.Transporter = (*Transport)(nil) type Transport struct { kind transport.Kind diff --git a/middleware/selector/selector_test.go b/middleware/selector/selector_test.go index 667d2755f..f12943e43 100644 --- a/middleware/selector/selector_test.go +++ b/middleware/selector/selector_test.go @@ -10,7 +10,7 @@ import ( "github.com/go-kratos/kratos/v2/transport" ) -var _ transport.Transporter = &Transport{} +var _ transport.Transporter = (*Transport)(nil) type Transport struct { kind transport.Kind diff --git a/middleware/tracing/tracing_test.go b/middleware/tracing/tracing_test.go index 8de2ceea4..222a6accd 100644 --- a/middleware/tracing/tracing_test.go +++ b/middleware/tracing/tracing_test.go @@ -14,7 +14,7 @@ import ( "go.opentelemetry.io/otel/trace" ) -var _ transport.Transporter = &mockTransport{} +var _ transport.Transporter = (*mockTransport)(nil) type headerCarrier http.Header diff --git a/selector/p2c/p2c.go b/selector/p2c/p2c.go index 6f8d5a3fa..5e339b0c2 100644 --- a/selector/p2c/p2c.go +++ b/selector/p2c/p2c.go @@ -17,7 +17,7 @@ const ( Name = "p2c" ) -var _ selector.Balancer = &Balancer{} +var _ selector.Balancer = (*Balancer)(nil) // Option is random builder option. type Option func(o *options) diff --git a/selector/random/random.go b/selector/random/random.go index cf59534d0..3af52d416 100644 --- a/selector/random/random.go +++ b/selector/random/random.go @@ -13,7 +13,7 @@ const ( Name = "random" ) -var _ selector.Balancer = &Balancer{} // Name is balancer name +var _ selector.Balancer = (*Balancer)(nil) // Name is balancer name // Option is random builder option. type Option func(o *options) diff --git a/selector/wrr/wrr.go b/selector/wrr/wrr.go index 0b95e04fb..3d91d62e3 100644 --- a/selector/wrr/wrr.go +++ b/selector/wrr/wrr.go @@ -13,7 +13,7 @@ const ( Name = "wrr" ) -var _ selector.Balancer = &Balancer{} // Name is balancer name +var _ selector.Balancer = (*Balancer)(nil) // Name is balancer name // Option is random builder option. type Option func(o *options) diff --git a/transport/grpc/transport.go b/transport/grpc/transport.go index a11a271ae..866228d1d 100644 --- a/transport/grpc/transport.go +++ b/transport/grpc/transport.go @@ -6,7 +6,7 @@ import ( "google.golang.org/grpc/metadata" ) -var _ transport.Transporter = &Transport{} +var _ transport.Transporter = (*Transport)(nil) // Transport is a gRPC transport. type Transport struct { diff --git a/transport/http/transport.go b/transport/http/transport.go index c377b5ad9..e7f53f6db 100644 --- a/transport/http/transport.go +++ b/transport/http/transport.go @@ -7,7 +7,7 @@ import ( "github.com/go-kratos/kratos/v2/transport" ) -var _ Transporter = &Transport{} +var _ Transporter = (*Transport)(nil) // Transporter is http Transporter type Transporter interface { From 0ed01efdfd1316b688602e041093e7ac8d384b27 Mon Sep 17 00:00:00 2001 From: "jesse.tang" <1430482733@qq.com> Date: Thu, 15 Sep 2022 20:10:39 +0800 Subject: [PATCH 22/46] revise err logic or null pointer exception (#2376) --- config/reader_test.go | 6 ------ contrib/config/polaris/config_test.go | 6 +++--- transport/transport_test.go | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/config/reader_test.go b/config/reader_test.go index f2ac1444b..15f8f6178 100644 --- a/config/reader_test.go +++ b/config/reader_test.go @@ -132,9 +132,6 @@ a: t.Fatal(`vvv is not equal to 1`) } - if err != nil { - t.Fatal(`err is not nil`) - } vv, ok = r.Value("a.b.Y") if !ok { t.Fatal(`ok is false`) @@ -147,9 +144,6 @@ a: t.Fatal(`vvy is not equal to "lol"`) } - if err != nil { - t.Fatal(`err is not nil`) - } vv, ok = r.Value("a.b.z") if !ok { t.Fatal(`ok is false`) diff --git a/contrib/config/polaris/config_test.go b/contrib/config/polaris/config_test.go index bf8b6fd61..9559174fa 100644 --- a/contrib/config/polaris/config_test.go +++ b/contrib/config/polaris/config_test.go @@ -26,13 +26,13 @@ var ( func makeJSONRequest(uri string, data string, method string, headers map[string]string) ([]byte, error) { client := http.Client{} req, err := http.NewRequest(method, uri, strings.NewReader(data)) + if err != nil { + return nil, err + } req.Header.Add("Content-Type", "application/json") for k, v := range headers { req.Header.Add(k, v) } - if err != nil { - return nil, err - } res, err := client.Do(req) if err != nil { return nil, err diff --git a/transport/transport_test.go b/transport/transport_test.go index b83c8ee3c..cba7f2ae1 100644 --- a/transport/transport_test.go +++ b/transport/transport_test.go @@ -53,7 +53,7 @@ func TestServerTransport(t *testing.T) { t.Errorf("expected:%v got:%v", true, ok) } if mtr == nil { - t.Errorf("expected:%v got:%v", nil, mtr) + t.Fatalf("expected:%v got:%v", nil, mtr) } if mtr.Kind().String() != KindGRPC.String() { t.Errorf("expected:%v got:%v", KindGRPC.String(), mtr.Kind().String()) From b0b49be38393082193c530e410fa6c42012eb23d Mon Sep 17 00:00:00 2001 From: "jesse.tang" <1430482733@qq.com> Date: Thu, 15 Sep 2022 20:13:08 +0800 Subject: [PATCH 23/46] feat: remote assert libraries (#2372) --- contrib/log/logrus/go.mod | 1 - contrib/log/logrus/go.sum | 1 - contrib/log/logrus/logrus_test.go | 5 +- contrib/registry/servicecomb/go.mod | 4 - contrib/registry/servicecomb/go.sum | 16 ---- contrib/registry/servicecomb/registry_test.go | 77 +++++++++++++------ 6 files changed, 56 insertions(+), 48 deletions(-) diff --git a/contrib/log/logrus/go.mod b/contrib/log/logrus/go.mod index aa1f59465..c41e4ecc7 100644 --- a/contrib/log/logrus/go.mod +++ b/contrib/log/logrus/go.mod @@ -5,7 +5,6 @@ go 1.16 require ( github.com/go-kratos/kratos/v2 v2.5.0 github.com/sirupsen/logrus v1.8.1 - github.com/stretchr/testify v1.7.1 ) replace github.com/go-kratos/kratos/v2 => ../../../ diff --git a/contrib/log/logrus/go.sum b/contrib/log/logrus/go.sum index 129b0363b..c8ee9b374 100644 --- a/contrib/log/logrus/go.sum +++ b/contrib/log/logrus/go.sum @@ -154,7 +154,6 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/contrib/log/logrus/logrus_test.go b/contrib/log/logrus/logrus_test.go index 3dcd6e64f..50b7a99b4 100644 --- a/contrib/log/logrus/logrus_test.go +++ b/contrib/log/logrus/logrus_test.go @@ -7,7 +7,6 @@ import ( "github.com/go-kratos/kratos/v2/log" "github.com/sirupsen/logrus" - "github.com/stretchr/testify/assert" ) func TestLoggerLog(t *testing.T) { @@ -58,7 +57,9 @@ func TestLoggerLog(t *testing.T) { wrapped := NewLogger(logger) _ = wrapped.Log(test.logLevel, test.kvs...) - assert.True(t, strings.HasPrefix(output.String(), test.want)) + if !strings.HasPrefix(output.String(), test.want) { + t.Errorf("TestName(%s): %s has not prefix %s", name, output.String(), test.want) + } }) } } diff --git a/contrib/registry/servicecomb/go.mod b/contrib/registry/servicecomb/go.mod index 43661281a..b5cb1c42a 100644 --- a/contrib/registry/servicecomb/go.mod +++ b/contrib/registry/servicecomb/go.mod @@ -7,9 +7,5 @@ require ( github.com/go-chassis/sc-client v0.6.1-0.20210615014358-a45e9090c751 github.com/go-kratos/kratos/v2 v2.3.1 github.com/gofrs/uuid v4.2.0+incompatible -) - -require ( - github.com/stretchr/testify v1.7.1 golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 ) diff --git a/contrib/registry/servicecomb/go.sum b/contrib/registry/servicecomb/go.sum index 738943dbe..015d1508a 100644 --- a/contrib/registry/servicecomb/go.sum +++ b/contrib/registry/servicecomb/go.sum @@ -137,9 +137,7 @@ github.com/go-openapi/jsonpointer v0.0.0-20160704185906-46af16f9f7b1/go.mod h1:+ github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1:W3Z9FmVs9qj+KR4zFKmDPGiLdk1D9Rlm7cyMvf57TTg= github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= -github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= -github.com/go-playground/form/v4 v4.2.0 h1:N1wh+Goz61e6w66vo8vJkQt+uwZSoLz50kZPJWR8eic= github.com/go-playground/form/v4 v4.2.0/go.mod h1:q1a2BY+AQUUzhl6xA/6hBetay6dEIhMHjgvJiGo6K7U= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= @@ -204,7 +202,6 @@ github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -219,7 +216,6 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/gofuzz v0.0.0-20161122191042-44d81051d367/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -229,14 +225,12 @@ github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OI github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsCZ4ayReDTBIg8b9dl28c5xFWyhBTVRp3pOg5EKY= github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= @@ -302,11 +296,9 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= github.com/little-cui/etcdadpt v0.3.2/go.mod h1:HnRRpIrVEVNWobkiCvG2EHLWKKZ+L047EcI29ma2zA4= @@ -548,7 +540,6 @@ golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220513210516-0976fa681c29 h1:w8s32wxx3sY+OjLlv9qltkLU5yvJzxjjgiHWLjdIcw4= golang.org/x/sync v0.0.0-20220513210516-0976fa681c29/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20170830134202-bb24a47a89ea/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -589,7 +580,6 @@ golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -597,7 +587,6 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -636,7 +625,6 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= @@ -660,7 +648,6 @@ google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfG google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd h1:e0TwkXOdbnH/1x5rc5MZ/VYyiZ4v+RdVfrGMqEwT68I= google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= @@ -674,7 +661,6 @@ google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAG google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.46.2 h1:u+MLGgVf7vRdjEYZ8wDFhAVNmhkbJ5hmrA1LMWK1CAQ= google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -688,12 +674,10 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= diff --git a/contrib/registry/servicecomb/registry_test.go b/contrib/registry/servicecomb/registry_test.go index d100c68a1..85afe306c 100644 --- a/contrib/registry/servicecomb/registry_test.go +++ b/contrib/registry/servicecomb/registry_test.go @@ -6,17 +6,14 @@ import ( pb "github.com/go-chassis/cari/discovery" "github.com/go-chassis/sc-client" - "github.com/go-kratos/kratos/v2/registry" "github.com/gofrs/uuid" - "github.com/stretchr/testify/assert" ) var r *Registry func init() { - c := &mockClient{} - r = NewRegistry(c) + r = NewRegistry(&mockClient{}) } type mockClient struct{} @@ -28,7 +25,6 @@ func (receiver *mockClient) WatchMicroService(microServiceID string, callback fu //nolint func (receiver *mockClient) FindMicroServiceInstances(consumerID, appID, microServiceName, versionRule string, opts ...sc.CallOption, - ) ([]*pb.MicroServiceInstance, error) { if microServiceName == "KratosServicecomb" { return []*pb.MicroServiceInstance{{}}, nil @@ -56,10 +52,11 @@ func (receiver *mockClient) GetMicroServiceID(appID, microServiceName, version, return "", nil } -// TestRegistry func TestRegistry(t *testing.T) { instanceID, err := uuid.NewV4() - assert.NoError(t, err) + if err != nil { + t.Fatal(err) + } svc := ®istry.ServiceInstance{ Name: "KratosServicecomb", Version: "0.0.1", @@ -70,25 +67,34 @@ func TestRegistry(t *testing.T) { ctx := context.TODO() t.Run("Register test, expected: success.", func(t *testing.T) { err = r.Register(ctx, svc) - assert.NoError(t, err) + if err != nil { + t.Error(err) + } }) t.Run("GetService test, expected: success.", func(t *testing.T) { var insts []*registry.ServiceInstance insts, err = r.GetService(ctx, svc.Name) - assert.NoError(t, err) - assert.Greater(t, len(insts), 0) + if err != nil { + t.Fatal(err) + } + if len(insts) <= 0 { + t.Errorf("inst len less than 0") + } }) t.Run("Deregister test, expected: success.", func(t *testing.T) { svc.ID = instanceID.String() err = r.Deregister(ctx, svc) - assert.NoError(t, err) + if err != nil { + t.Error(err) + } }) } func TestWatcher(t *testing.T) { - ctx := context.TODO() instanceID1, err := uuid.NewV4() - assert.NoError(t, err) + if err != nil { + t.Fatal(err) + } svc1 := ®istry.ServiceInstance{ Name: "WatcherTest", Version: "0.0.1", @@ -96,33 +102,56 @@ func TestWatcher(t *testing.T) { Endpoints: []string{"tcp://127.0.0.1:9000?isSecure=false"}, ID: instanceID1.String(), } + ctx := context.TODO() err = r.Register(ctx, svc1) - assert.NoError(t, err) + if err != nil { + t.Fatal(err) + } w, err := r.Watch(ctx, "WatcherTest") - assert.NoError(t, err) - assert.NotEmpty(t, w) + if err != nil { + t.Fatal(err) + } + if w == nil { + t.Fatal("w is nil") + } sbWatcher := w.(*Watcher) t.Run("Watch register event, expected: success", func(t *testing.T) { go sbWatcher.Put(svc1) var instances []*registry.ServiceInstance instances, err = w.Next() - assert.NoError(t, err) - assert.NotEmpty(t, instances) - assert.Equal(t, instanceID1.String(), instances[0].ID) + if err != nil { + t.Fatal(err) + } + if len(instances) == 0 { + t.Errorf("instances is empty") + } + if instanceID1.String() != instances[0].ID { + t.Errorf("expected %v, got %v", instanceID1.String(), instances[0].ID) + } }) t.Run("Watch deregister event, expected: success", func(t *testing.T) { // Deregister instance1. err = r.Deregister(ctx, svc1) - assert.NoError(t, err) + if err != nil { + t.Fatal(err) + } go sbWatcher.Put(svc1) var instances []*registry.ServiceInstance instances, err = w.Next() - assert.NoError(t, err) - assert.NotEmpty(t, instances) - assert.Equal(t, instanceID1.String(), instances[0].ID) + if err != nil { + t.Fatal(err) + } + if len(instances) == 0 { + t.Errorf("instances is empty") + } + if instanceID1.String() != instances[0].ID { + t.Errorf("expected %v, got %v", instanceID1.String(), instances[0].ID) + } }) t.Run("Stop test, expected: success", func(t *testing.T) { err = w.Stop() - assert.NoError(t, err) + if err != nil { + t.Error(err) + } }) } From d3f80c10612c5050d30219a6f8ee3765f3046eff Mon Sep 17 00:00:00 2001 From: Loner1024 Date: Thu, 15 Sep 2022 20:13:51 +0800 Subject: [PATCH 24/46] test: supplement the unit testing of transport/grpc (#2371) * test:grpc codec test * style:go fmt * refactor:delete useless code * style:go fmt --- transport/grpc/codec_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 transport/grpc/codec_test.go diff --git a/transport/grpc/codec_test.go b/transport/grpc/codec_test.go new file mode 100644 index 000000000..534439ff9 --- /dev/null +++ b/transport/grpc/codec_test.go @@ -0,0 +1,28 @@ +package grpc + +import ( + "reflect" + "testing" + + "google.golang.org/protobuf/types/known/structpb" +) + +func TestCodec(t *testing.T) { + in, err := structpb.NewStruct(map[string]interface{}{"Golang": "Kratos"}) + if err != nil { + t.Errorf("grpc codec create input data error:%v", err) + } + c := codec{} + data, err := c.Marshal(in) + if err != nil { + t.Errorf("grpc codec marshal error:%v", err) + } + out := &structpb.Struct{} + err = c.Unmarshal(data, out) + if err != nil { + t.Errorf("grpc codec unmarshal error:%v", err) + } + if !reflect.DeepEqual(in, out) { + t.Errorf("grpc codec want %v, got %v", in, out) + } +} From 7a320233cd157ecede1744eeef4918c9636f609c Mon Sep 17 00:00:00 2001 From: "jesse.tang" <1430482733@qq.com> Date: Thu, 15 Sep 2022 20:15:07 +0800 Subject: [PATCH 25/46] fix: .gitignore del Repeated .*so (#2367) --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 0384a2c2f..260c599e2 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ *.exe *.exe~ *.dll -*.so *.dylib # Test binary, built with `go test -c` From 7f2666be9f86e1a37b1e16656e34c234b22deb30 Mon Sep 17 00:00:00 2001 From: Jiepeng Cao Date: Thu, 15 Sep 2022 21:31:13 +0800 Subject: [PATCH 26/46] typo for log (#2374) --- contrib/opensergo/opensergo_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/opensergo/opensergo_test.go b/contrib/opensergo/opensergo_test.go index 9f49bbeef..b63430e20 100644 --- a/contrib/opensergo/opensergo_test.go +++ b/contrib/opensergo/opensergo_test.go @@ -338,7 +338,7 @@ func TestOpenSergo(t *testing.T) { fileContent := `{"endpoint": "127.0.0.1:9090"}` err := os.WriteFile("test.json", []byte(fileContent), 0o644) if err != nil { - t.Fatalf("ioutil.WriteFile error:%s", err) + t.Fatalf("os.WriteFile error:%s", err) } confPath, err := filepath.Abs("./test.json") if err != nil { From 9737a3c5e43456ec64244cae15949f9e9f152443 Mon Sep 17 00:00:00 2001 From: "jesse.tang" <1430482733@qq.com> Date: Mon, 19 Sep 2022 10:39:54 +0800 Subject: [PATCH 27/46] fix: typo and grammatical errors (#2368) * fix: grammar * fix: grammar * fix overrode * translate to English * translate to English --- .github/ISSUE_TEMPLATE/feature-request.md | 2 +- CONTRIBUTING.md | 8 ++++---- cmd/protoc-gen-go-http/http.go | 4 ++-- contrib/config/etcd/README.md | 2 +- contrib/log/aliyun/aliyun.go | 2 +- contrib/metrics/datadog/options.go | 2 +- contrib/registry/consul/client.go | 2 +- contrib/registry/discovery/discovery.go | 2 +- contrib/registry/etcd/registry.go | 2 +- contrib/registry/eureka/eureka.go | 6 +++--- contrib/registry/kubernetes/registry.go | 2 +- encoding/encoding_test.go | 2 +- encoding/form/proto_decode.go | 2 +- errors/types.go | 10 +++++----- internal/group/group.go | 2 +- log/global_test.go | 2 +- log/helper_writer.go | 2 +- middleware/circuitbreaker/circuitbreaker.go | 4 ++-- middleware/logging/logging.go | 2 +- middleware/metadata/metadata_test.go | 2 +- middleware/tracing/span.go | 10 ++++++---- registry/registry.go | 2 +- selector/random/random.go | 2 +- selector/selector_test.go | 2 +- transport/grpc/balancer.go | 2 +- transport/http/client.go | 2 +- transport/http/filter.go | 2 +- transport/http/status/status.go | 2 +- 28 files changed, 44 insertions(+), 42 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md index c8cc2f816..eeaf24273 100644 --- a/.github/ISSUE_TEMPLATE/feature-request.md +++ b/.github/ISSUE_TEMPLATE/feature-request.md @@ -43,7 +43,7 @@ example: ### Requirements description of the feature ### References