Documentation
¶
Index ¶
- type File
- func (config *File) Get(fields string) (interface{}, error)
- func (config *File) GetConfigDirPath() (string, error)
- func (config *File) GetConfigFilePath() (string, error)
- func (config *File) Parse() error
- func (config *File) Save() error
- func (config *File) SetupUserConfig() (bool, bool, error)
- func (config *File) Stringify() (string, error)
- type LircSection
- type VideoSection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type File ¶
type File struct { Video VideoSection `toml:"video"` Lirc LircSection `toml:"lirc"` }
File represents the fields and sections in the configuration file.
func (*File) Get ¶
Get retrieves a section or a value from a key in a section.
fields is either only the section name e.g. lirc or a value from the section e.g. lirc.remote
Returns a generic interface that you can use type assertions to work with the type it actually is e.g. to the return value containing the interface from the call Get("lirc") you could use .(LircSection).SocketPath to retrieve the socket path value from that section.
func (*File) GetConfigDirPath ¶
GetConfigDirPath retrieves the absolute path to the configuration directory in an OS independent way.
Returns: (absolute path to the configuration direction, any error) If an error occurs, an empty string is returned as the path.
func (*File) GetConfigFilePath ¶
GetConfigFilePath retrieves the absolute path to the configuration file in an OS independent way.
Lookup hierarchy:
- HC_CONFIG_PATH environment variable. This will only be used if the path set in the environment variable is file that exists.
- ~/.stb/config.toml will be looked for next. This is the configuration path to the user-defined configuration.
- Internal config file in the package will be used. This is the configuration file that is used by default if the above two do not exist.
Returns: (the absolute path to configuration file, any error) If an error occurs, an empty string is returned as the path.
func (*File) Parse ¶
Parse parses the config file and reads the fields into this File. After it is parsed, you can then directly access the fields.
Example:
config.Parse() config.video.device = "/dev/device0" config.Save()
func (*File) SetupUserConfig ¶
SetupUserConfig initializes the user's configuration file setup by creating the configuration folder at ~/.stb/ and configuration file at ~/.stb/config.toml. It only creates these if they do not exist already.
Returns: (if folder is created, if file is created, any error)
type LircSection ¶
LircSection holds the values for the lirc section in the configuration file.
type VideoSection ¶
type VideoSection struct {
DeviceId int `toml:"deviceId"`
}
VideoSection holds the values for the video section in the configuration file.