package models
import (
"bytes"
"encoding/gob"
)
// ConfigEntry is the actual object saved to the database.
// The Value is encoded using encoding/gob.
type ConfigEntry struct {
Value interface{}
Key string
}
func (c *ConfigEntry) GetStringSlice() ([]string, error) {
decoder := c.GetDecoder()
var result []string
err := decoder.Decode(&result)
return result, err
func (c *ConfigEntry) GetStringMap() (map[string]string, error) {
var result map[string]string
func (c *ConfigEntry) GetString() (string, error) {
var result string
func (c *ConfigEntry) GetNumber() (float64, error) {
var result float64
func (c *ConfigEntry) GetBool() (bool, error) {
var result bool
func (c *ConfigEntry) GetObject(result interface{}) error {
err := decoder.Decode(result)
return err
func (c *ConfigEntry) GetDecoder() *gob.Decoder {
valueBytes := c.Value.([]byte)
decoder := gob.NewDecoder(bytes.NewBuffer(valueBytes))
return decoder