Documentation
¶
Index ¶
- Variables
- func GetConfigPath() string
- func GetSchema(structure interface{}) *cs.ValueTypeDescriptor
- func Load(structure interface{}) error
- func Save(structure interface{}) error
- func SetCoreName(corename string)
- func SetDevMode(devmode bool)
- func SetName(corename string)
- func SetSAGUIMode(saGuiMode bool)
- func ValidateConfig(schema *cs.ValueTypeDescriptor, values interface{}, strictMode bool, ...) (cleanedValue interface{}, e error)
- type BaseDeviceConfig
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var SAGuiMode bool = false
Functions ¶
func GetConfigPath ¶
func GetConfigPath() string
func GetSchema ¶
func GetSchema(structure interface{}) *cs.ValueTypeDescriptor
Returns the current schema for a core
func Load ¶
func Load(structure interface{}) error
Load a package config, also storing the default config and schema for ibeam-init to pick up
Example ¶
package main
import (
"fmt"
"net"
conf "github.com/SKAARHOJ/ibeam-lib-config"
)
func main() {
type GlobalConfig struct {
FunnyString string
FunnyStringRay []string
FunnyStringRay_Double [][]string
FunnyIntRayDOUBLE [][]uint16
FunnyBool bool
}
type DeviceConfig struct {
IPAddress net.IP
Port uint16
SomeConfigName string
DeviceID int
Stringoray []string
Active bool
}
type Config struct {
Global GlobalConfig
Devices []DeviceConfig
}
// Define config filled with all defaults
var config = Config{
Global: GlobalConfig{
FunnyStringRay: []string{"Hi people"},
FunnyStringRay_Double: [][]string{
{"Hi people"},
},
},
Devices: []DeviceConfig{
{Port: 20},
{Port: 20},
{Port: 20},
},
}
conf.SetDevMode(true) // only use this in development
conf.SetCoreName("core-template")
err := conf.Load(&config)
if err != nil {
fmt.Println(err)
}
}
Output:
func SetCoreName ¶
func SetCoreName(corename string)
SetCoreName sets the name of the core and therefore the files (sane as SetName)
func SetDevMode ¶
func SetDevMode(devmode bool)
SetDevMode activates the development mode path configuration
func SetName ¶
func SetName(corename string)
SetName sets the name of the package and therefore the files
func SetSAGUIMode ¶
func SetSAGUIMode(saGuiMode bool)
SetSAGUIMode activates the standard-alone GUI mode path configuration (Mac OS, Windows, Linux delivered as a signed Wails application for example)
func ValidateConfig ¶
func ValidateConfig(schema *cs.ValueTypeDescriptor, values interface{}, strictMode bool, nameForWarnings string) (cleanedValue interface{}, e error)
ValidateConfig validates a config structure against a schema, osed in different places to validate the correctness of configs. It also fixes the int types that get lost by json using float64 for everything. The result is returned as cleanedValues Pass strict mode to return errors when additional values are found in the config
Types ¶
type BaseDeviceConfig ¶
type BaseDeviceConfig struct {
Active bool `ibOrder:"1" ibDispatch:"active"`
Name string `ibOrder:"5" ibDispatch:"name" ibDescription:""`
DeviceID uint32 `` /* 135-byte string literal not displayed */
ModelID uint32 `ibLabel:"Model Id" ibOrder:"15" ibDispatch:"modelid" ibDescription:"The model type of the device"`
Description string `ibOrder:"20" ibDispatch:"description"`
}
func (BaseDeviceConfig) GetDeviceID ¶
func (b BaseDeviceConfig) GetDeviceID() uint32