Implement IsSet method
This commit is contained in:
parent
88e928e51a
commit
2b8b235752
11
ini.go
11
ini.go
@ -197,6 +197,15 @@ func (config *Configuration) GetAsBooleans(path string) []bool {
|
||||
return key.Bools(",")
|
||||
}
|
||||
|
||||
func (config *Configuration) IsSet(path string) bool {
|
||||
key, err := config.GetKey(path)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return key.Value() != ""
|
||||
}
|
||||
|
||||
func (config *Configuration) load() {
|
||||
if _, err := os.Stat(config.fileLocation); err != nil {
|
||||
file, err := os.Create(config.fileLocation)
|
||||
@ -204,7 +213,7 @@ func (config *Configuration) load() {
|
||||
fmt.Printf("Failed to create configuration file: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
_, err = file.WriteString("[General]\nserver = sfs.example.com\nport = 7392\nusername = user\nauth-token = token\n; http:// or https:// is necessary\n; port is optional\nhttp-server = http://sfs.example.com:80\npublic-key =\n\n[Share]\nsync-interval = 60")
|
||||
_, err = file.WriteString("")
|
||||
if err != nil {
|
||||
fmt.Printf("Error creating configuration file: %v", err)
|
||||
os.Exit(1)
|
||||
|
Loading…
Reference in New Issue
Block a user