Last active
January 7, 2018 16:50
-
-
Save fnzv/fce6fb504f45405f947c4f856e27fc2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"os" | |
"fmt" | |
"github.com/BurntSushi/toml" | |
) | |
// Info from config file | |
type Config struct { | |
test int | |
testb int | |
testc int | |
} | |
// Reads info from config file | |
func ReadConfig() Config { | |
var configfile = "test.conf" | |
_, err := os.Stat(configfile) | |
if err != nil { | |
fmt.Println("Config file is missing: ", configfile) | |
} | |
var config Config | |
if _, err := toml.DecodeFile(configfile, &config); err != nil { | |
fmt.Println(err) | |
} | |
//log.Print(config.Index) | |
return config | |
} | |
func main() { | |
var config = ReadConfig() | |
fmt.Println("test",config.test) | |
fmt.Println("testb",config.testb) | |
fmt.Println("testc",config.testc) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test = 0 | |
testb = 1 | |
testc = 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment