From fd09bebedcfe815ec59c12989c9bd1ea4d073c7b Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Mon, 18 Jul 2016 22:59:08 +0100 Subject: [PATCH] Add Str convenience method for KV items --- kvs/boltdb/kv.go | 5 +++++ kvs/kv.go | 1 + kvs/mysql/kv.go | 5 +++++ kvs/pgsql/kv.go | 5 +++++ 4 files changed, 16 insertions(+) diff --git a/kvs/boltdb/kv.go b/kvs/boltdb/kv.go index 000498fe..5700b097 100644 --- a/kvs/boltdb/kv.go +++ b/kvs/boltdb/kv.go @@ -35,3 +35,8 @@ func (kv *KV) Key() []byte { func (kv *KV) Val() []byte { return kv.val } + +// Str returns a string of the value +func (kv *KV) Str() string { + return string(kv.val) +} diff --git a/kvs/kv.go b/kvs/kv.go index 730d5b9e..07f35566 100644 --- a/kvs/kv.go +++ b/kvs/kv.go @@ -19,4 +19,5 @@ type KV interface { Exists() bool Key() []byte Val() []byte + Str() string } diff --git a/kvs/mysql/kv.go b/kvs/mysql/kv.go index fa2a3160..181dc8e4 100644 --- a/kvs/mysql/kv.go +++ b/kvs/mysql/kv.go @@ -35,3 +35,8 @@ func (kv *KV) Key() []byte { func (kv *KV) Val() []byte { return kv.val } + +// Str returns a string of the value +func (kv *KV) Str() string { + return string(kv.val) +} diff --git a/kvs/pgsql/kv.go b/kvs/pgsql/kv.go index 44f40269..e1193002 100644 --- a/kvs/pgsql/kv.go +++ b/kvs/pgsql/kv.go @@ -35,3 +35,8 @@ func (kv *KV) Key() []byte { func (kv *KV) Val() []byte { return kv.val } + +// Str returns a string of the value +func (kv *KV) Str() string { + return string(kv.val) +}