fix lint
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
3bc046e5d4
commit
15c020fac5
@ -30,7 +30,7 @@ linters:
|
|||||||
- gofmt
|
- gofmt
|
||||||
- gofumpt
|
- gofumpt
|
||||||
- goimports
|
- goimports
|
||||||
- golint
|
- revive
|
||||||
- gosec
|
- gosec
|
||||||
- makezero
|
- makezero
|
||||||
- misspell
|
- misspell
|
||||||
|
@ -107,13 +107,16 @@ func New(size int) Metadata {
|
|||||||
|
|
||||||
// Merge merges metadata to existing metadata, overwriting if specified
|
// Merge merges metadata to existing metadata, overwriting if specified
|
||||||
func Merge(omd Metadata, mmd Metadata, overwrite bool) Metadata {
|
func Merge(omd Metadata, mmd Metadata, overwrite bool) Metadata {
|
||||||
|
var ok bool
|
||||||
nmd := Copy(omd)
|
nmd := Copy(omd)
|
||||||
for key, val := range mmd {
|
for key, val := range mmd {
|
||||||
if _, ok := nmd[key]; ok && !overwrite {
|
_, ok = nmd[key]
|
||||||
// skip
|
switch {
|
||||||
} else if val != "" {
|
case ok && !overwrite:
|
||||||
|
continue
|
||||||
|
case val != "":
|
||||||
nmd.Set(key, val)
|
nmd.Set(key, val)
|
||||||
} else {
|
case ok && val == "":
|
||||||
nmd.Del(key)
|
nmd.Del(key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,11 +41,12 @@ func TestTrieMatchRegexp(t *testing.T) {
|
|||||||
tr.Insert([]string{http.MethodPut}, "/v1/create/{category}/{id:[0-9]+}", &handler{})
|
tr.Insert([]string{http.MethodPut}, "/v1/create/{category}/{id:[0-9]+}", &handler{})
|
||||||
|
|
||||||
_, params, ok := tr.Search(http.MethodPut, "/v1/create/test_cat/12345")
|
_, params, ok := tr.Search(http.MethodPut, "/v1/create/test_cat/12345")
|
||||||
if !ok {
|
switch {
|
||||||
|
case !ok:
|
||||||
t.Fatalf("route not found")
|
t.Fatalf("route not found")
|
||||||
} else if len(params) != 2 {
|
case len(params) != 2:
|
||||||
t.Fatalf("param matching error %v", params)
|
t.Fatalf("param matching error %v", params)
|
||||||
} else if params["category"] != "test_cat" {
|
case params["category"] != "test_cat":
|
||||||
t.Fatalf("param matching error %v", params)
|
t.Fatalf("param matching error %v", params)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user