From b96cdc79dcc576b06a20ea3c7e715811e57e77f7 Mon Sep 17 00:00:00 2001 From: Tobie Morgan Hitchcock Date: Fri, 24 Nov 2017 10:54:21 +0000 Subject: [PATCH] Implement both TextMarshaler and TextUnmarshaler for codec If a type only defines one-half of the symmetry (e.g. it implements MarshalJSON() but not UnmarshalJSON() ), then that type doesn't satisfy the codec encoding/decoding check and instead codec will not encode or decode the item using the special interface methods. --- cnf/cnf.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cnf/cnf.go b/cnf/cnf.go index 15619b57..78745d64 100644 --- a/cnf/cnf.go +++ b/cnf/cnf.go @@ -23,10 +23,6 @@ var Settings *Options type Kind int -func (k Kind) MarshalText() (data []byte, err error) { - return []byte(k.String()), err -} - func (k Kind) String() string { switch k { default: @@ -42,6 +38,14 @@ func (k Kind) String() string { } } +func (k Kind) MarshalText() (data []byte, err error) { + return []byte(k.String()), err +} + +func (k Kind) UnmarshalText(text []byte) error { + return nil +} + const ( // Root access AuthKV Kind = iota