mirror of
				https://github.com/owncast/owncast.git
				synced 2025-10-31 10:08:10 +08:00 
			
		
		
		
	 0b5d7c8a4d
			
		
	
	0b5d7c8a4d
	
	
	
		
			
			* WIP * fix(test): fix ap test failing * fix: fix unkeyed fields being used * chore(tests): clean up browser tests by splitting out federation UI tests
		
			
				
	
	
		
			61 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			61 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| 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) {
 | |
| 	decoder := c.GetDecoder()
 | |
| 	var result map[string]string
 | |
| 	err := decoder.Decode(&result)
 | |
| 	return result, err
 | |
| }
 | |
| 
 | |
| func (c *ConfigEntry) GetString() (string, error) {
 | |
| 	decoder := c.GetDecoder()
 | |
| 	var result string
 | |
| 	err := decoder.Decode(&result)
 | |
| 	return result, err
 | |
| }
 | |
| 
 | |
| func (c *ConfigEntry) GetNumber() (float64, error) {
 | |
| 	decoder := c.GetDecoder()
 | |
| 	var result float64
 | |
| 	err := decoder.Decode(&result)
 | |
| 	return result, err
 | |
| }
 | |
| 
 | |
| func (c *ConfigEntry) GetBool() (bool, error) {
 | |
| 	decoder := c.GetDecoder()
 | |
| 	var result bool
 | |
| 	err := decoder.Decode(&result)
 | |
| 	return result, err
 | |
| }
 | |
| 
 | |
| func (c *ConfigEntry) GetObject(result interface{}) error {
 | |
| 	decoder := c.GetDecoder()
 | |
| 	err := decoder.Decode(result)
 | |
| 	return err
 | |
| }
 | |
| 
 | |
| func (c *ConfigEntry) GetDecoder() *gob.Decoder {
 | |
| 	valueBytes := c.Value.([]byte)
 | |
| 	decoder := gob.NewDecoder(bytes.NewBuffer(valueBytes))
 | |
| 	return decoder
 | |
| }
 |