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
|
||||
- gofumpt
|
||||
- goimports
|
||||
- golint
|
||||
- revive
|
||||
- gosec
|
||||
- makezero
|
||||
- misspell
|
||||
|
@ -107,13 +107,16 @@ func New(size int) Metadata {
|
||||
|
||||
// Merge merges metadata to existing metadata, overwriting if specified
|
||||
func Merge(omd Metadata, mmd Metadata, overwrite bool) Metadata {
|
||||
var ok bool
|
||||
nmd := Copy(omd)
|
||||
for key, val := range mmd {
|
||||
if _, ok := nmd[key]; ok && !overwrite {
|
||||
// skip
|
||||
} else if val != "" {
|
||||
_, ok = nmd[key]
|
||||
switch {
|
||||
case ok && !overwrite:
|
||||
continue
|
||||
case val != "":
|
||||
nmd.Set(key, val)
|
||||
} else {
|
||||
case ok && val == "":
|
||||
nmd.Del(key)
|
||||
}
|
||||
}
|
||||
|
@ -41,11 +41,12 @@ func TestTrieMatchRegexp(t *testing.T) {
|
||||
tr.Insert([]string{http.MethodPut}, "/v1/create/{category}/{id:[0-9]+}", &handler{})
|
||||
|
||||
_, params, ok := tr.Search(http.MethodPut, "/v1/create/test_cat/12345")
|
||||
if !ok {
|
||||
switch {
|
||||
case !ok:
|
||||
t.Fatalf("route not found")
|
||||
} else if len(params) != 2 {
|
||||
case len(params) != 2:
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user