1
0
Fork 0
mirror of https://github.com/eosswedenorg/antelope-api-healthcheck synced 2026-06-27 10:53:44 +02:00

src/api/log_params.go: Adding Combine()

This commit is contained in:
Henrik Hautakoski 2022-10-21 15:08:26 +02:00
parent 8d2c1c8fa3
commit 8079962be8
No known key found for this signature in database
GPG key ID: 608414D93E862CCD
2 changed files with 22 additions and 0 deletions

View file

@ -6,3 +6,9 @@ type LogParams []interface{}
func (p *LogParams) Add(field string, value interface{}) {
*p = append(*p, field, value)
}
// Syntactic sugar for append(p, other...)
// Returns a new instance of LogParams with all values from both p and other
func (p LogParams) Combine(other LogParams) LogParams {
return append(p, other...)
}

View file

@ -32,3 +32,19 @@ func TestLogParams(t *testing.T) {
assert.ElementsMatch(t, expected, p)
}
func TestLogParamsCombine(t *testing.T) {
a := LogParams{"one",1,"string1","str1"}
b := LogParams{"two",2,"string2","str2"}
expected := LogParams{
"one",1,
"string1","str1",
"two",2,
"string2","str2",
}
assert.Equal(t, expected, a.Combine(b))
}