beam/data: convenience Message.Get
Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
This commit is contained in:
parent
b78465fc2a
commit
cd44538901
1 changed files with 12 additions and 0 deletions
|
@ -42,6 +42,18 @@ func (m Message) Del(k string) Message {
|
|||
return Message(Encode(data))
|
||||
}
|
||||
|
||||
func (m Message) Get(k string) []string {
|
||||
data, err := Decode(string(m))
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
v, exists := data[k]
|
||||
if !exists {
|
||||
return nil
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
func (m Message) String() string {
|
||||
return string(m)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue