From b83a1e0227d6d9048d3494a0b322213fbaf4c298 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 22 Jan 2020 08:35:24 -0500 Subject: [PATCH] Add delete method for kvstore --- kvstore.go | 20 ++++++++++++++++++++ types.go | 1 + 2 files changed, 21 insertions(+) diff --git a/kvstore.go b/kvstore.go index 472f974..4764a51 100644 --- a/kvstore.go +++ b/kvstore.go @@ -103,3 +103,23 @@ func (kv KV) Put(namespace string, key string, value string) (KVAPI, error) { } return r, nil } + +// Delete removes an entry +func (kv KV) Delete(namespace string, key string) (KVAPI, error) { + m := KVAPI{ + Params: &kvParams{}, + } + m.Params.Options = kvOptions{ + Team: kv.Team, + Namespace: namespace, + EntryKey: key, + } + + m.Method = "del" + + r, err := kvAPIOut(kv.keybase, m) + if err != nil { + return r, err + } + return r, nil +} diff --git a/types.go b/types.go index 7581df6..06e8fa4 100644 --- a/types.go +++ b/types.go @@ -894,6 +894,7 @@ type kvInterface interface { Keys(namespace string) (KVAPI, error) Get(namespace string, key string) (KVAPI, error) Put(namespace string, key string, value string) (KVAPI, error) + Delete(namespace string, key string) (KVAPI, error) } type keybase interface {