github.com/cloudfoundry-attic/ltc@v0.0.0-20151123212628-098adc7919fc/config/persister/mem_persister.go (about)

     1  package persister
     2  
     3  import (
     4  	"encoding/json"
     5  )
     6  
     7  func NewMemPersister() Persister {
     8  	return &memPersister{}
     9  }
    10  
    11  type memPersister struct {
    12  	content []byte
    13  }
    14  
    15  func (m *memPersister) Load(data interface{}) error {
    16  	return json.Unmarshal(m.content, data)
    17  }
    18  
    19  func (m *memPersister) Save(data interface{}) error {
    20  	var err error
    21  	m.content, err = json.Marshal(data)
    22  	return err
    23  }