Documentation
¶
Overview ¶
Package ini is a default implementation of InterfaceIniConfig declared in "github.com/ottemo/commerce/env" package.
Ini config is a config.ini file where startup information located. Ini file could be separated on a sections (refer to https://github.com/vaughan0/go-ini) for ini file lookup. Ini config takes a value from ini file "current" section and if not found in there - looking for a global section.
Special section ConstTestSectionName ("test") used for "test mode" application startup. To start application in that mode ConstCmdArgTestFlag "--test" should be used.
Example 1: ---------- if iniConfig := env.GetIniConfig(); iniConfig != nil { if iniValue := iniConfig.GetValue("db.sqlite3.uri", uri); iniValue != "" { uri = iniValue } } Example 2: ---------- uri := env.IniValue("db.sqlite3.uri")
Index ¶
- Constants
- type DefaultIniConfig
- func (it *DefaultIniConfig) GetSectionValue(sectionName string, valueName string, defaultValue string) string
- func (it *DefaultIniConfig) GetValue(valueName string, defaultValue string) string
- func (it *DefaultIniConfig) ListItems() []string
- func (it *DefaultIniConfig) ListSectionItems(sectionName string) []string
- func (it *DefaultIniConfig) ListSections() []string
- func (it *DefaultIniConfig) SetValue(valueName string, value string) error
- func (it *DefaultIniConfig) SetWorkingSection(sectionName string) error
Constants ¶
const ( ConstIniGlobalSection = "" // ini file section name to be used as default section ConstAskForValuePrefix = "?" // prefix used before default ini value to be asked in console if not set ConstCmdArgStoreAllFlag = "--iniStoreAll" ConstCmdArgSectionName = "--iniSection=" ConstCmdArgTestFlag = "--test" ConstEnvironmentIniFile = "OTTEMO_INI" ConstEnvironmentIniSection = "OTTEMO_MODE" ConstTestSectionName = "test" ConstDefaultIniFile = "ottemo.ini" ConstBackupFileSuffix = ".bak" ConstErrorModule = "env/ini" ConstErrorLevel = env.ConstErrorLevelService )
Package global constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultIniConfig ¶
type DefaultIniConfig struct {
// contains filtered or unexported fields
}
DefaultIniConfig is a default implementer of InterfaceIniConfig
func (*DefaultIniConfig) GetSectionValue ¶
func (it *DefaultIniConfig) GetSectionValue(sectionName string, valueName string, defaultValue string) string
GetSectionValue returns value assigned to specified ini section only, or [defaultValue] if not assigned
func (*DefaultIniConfig) GetValue ¶
func (it *DefaultIniConfig) GetValue(valueName string, defaultValue string) string
GetValue returns specified value from ini file, looks for value in current section then in global
func (*DefaultIniConfig) ListItems ¶
func (it *DefaultIniConfig) ListItems() []string
ListItems returns all ini file values, for current and global sections
func (*DefaultIniConfig) ListSectionItems ¶
func (it *DefaultIniConfig) ListSectionItems(sectionName string) []string
ListSectionItems enumerates value names within specified ini section
func (*DefaultIniConfig) ListSections ¶
func (it *DefaultIniConfig) ListSections() []string
ListSections enumerates currently used ini sections
func (*DefaultIniConfig) SetValue ¶
func (it *DefaultIniConfig) SetValue(valueName string, value string) error
SetValue sets/updates current working section value, modified value marks for saving
func (*DefaultIniConfig) SetWorkingSection ¶
func (it *DefaultIniConfig) SetWorkingSection(sectionName string) error
SetWorkingSection changes working ini section to specified