Documentation ¶
Overview ¶
Example ¶
type Config struct { Server string Username string } config := Config{ "server1", "user1", } d := dot.New() err := d.Save(&config) if err != nil { panic(err) } configFolder, err := d.GetConfigFolder() if err != nil { panic(err) } fmt.Println("config folder : ", configFolder) configPath, err := d.GetConfigPath(&config) if err != nil { panic(err) } fmt.Println("config path : ", configPath) config2 := Config{} err = d.Load(&config2) if err != nil { panic(err) } fmt.Printf("%+v", config2)
Output:
Index ¶
- Constants
- type Dot
- func (d *Dot) ByFileFormat(ff FileFormat) *Dot
- func (d *Dot) ByFolder(f Folder) *Dot
- func (d *Dot) Dump() error
- func (d *Dot) GetConfigFolder() (string, error)
- func (d *Dot) GetConfigPath(configuration interface{}) (string, error)
- func (d *Dot) Load(configuration interface{}) error
- func (d *Dot) Save(configuration interface{}) error
- type FileFormat
- type Folder
Examples ¶
Constants ¶
View Source
const ( // YAML format YAML = ".yml" //JSON format JSON = ".json" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dot ¶
type Dot struct { AppName string Folder Folder FileFormat FileFormat }
Dot is the main struct of dot configuration library. Create with the dot.New() function.
func New ¶
func New() *Dot
New creates a new dot struct with default values. default app name is current executable name default folder type is HomeDir default FileFormat is yaml
func (*Dot) ByFileFormat ¶
func (d *Dot) ByFileFormat(ff FileFormat) *Dot
ByFileFormat set file format enum to Dot struct
func (*Dot) GetConfigFolder ¶
GetConfigFolder return full path of config folder
func (*Dot) GetConfigPath ¶
GetConfigPath return full path of config file
Click to show internal directories.
Click to hide internal directories.