From cd44538901217b9e21fb59ba1ceded4926894320 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Mon, 24 Mar 2014 18:16:27 -0700 Subject: [PATCH] beam/data: convenience Message.Get Docker-DCO-1.1-Signed-off-by: Solomon Hykes (github: shykes) --- beam/data/message.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/beam/data/message.go b/beam/data/message.go index 382308f..b35d880 100644 --- a/beam/data/message.go +++ b/beam/data/message.go @@ -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) }