From fa05b165ad488060669cb2902b6cd28d29341494 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 2 Oct 2014 13:42:36 -0700 Subject: [PATCH] config: fix gob encode/decode for raw config and keys --- config/raw_config.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/config/raw_config.go b/config/raw_config.go index 3b08d9570..f3b144800 100644 --- a/config/raw_config.go +++ b/config/raw_config.go @@ -153,11 +153,15 @@ func (r *RawConfig) UnknownKeys() []string { // See GobEncode func (r *RawConfig) GobDecode(b []byte) error { - err := gob.NewDecoder(bytes.NewReader(b)).Decode(&r.Raw) + var data gobRawConfig + err := gob.NewDecoder(bytes.NewReader(b)).Decode(&data) if err != nil { return err } + r.Key = data.Key + r.Raw = data.Raw + return r.init() } @@ -166,10 +170,20 @@ func (r *RawConfig) GobDecode(b []byte) error { // tree of interpolated variables is recomputed on decode, since it is // referentially transparent. func (r *RawConfig) GobEncode() ([]byte, error) { + data := gobRawConfig{ + Key: r.Key, + Raw: r.Raw, + } + var buf bytes.Buffer - if err := gob.NewEncoder(&buf).Encode(r.Raw); err != nil { + if err := gob.NewEncoder(&buf).Encode(data); err != nil { return nil, err } return buf.Bytes(), nil } + +type gobRawConfig struct { + Key string + Raw map[string]interface{} +}