Skip to content

Instantly share code, notes, and snippets.

@fnzv
Last active January 7, 2018 16:50
Show Gist options
  • Save fnzv/fce6fb504f45405f947c4f856e27fc2b to your computer and use it in GitHub Desktop.
Save fnzv/fce6fb504f45405f947c4f856e27fc2b to your computer and use it in GitHub Desktop.
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)
}
test = 0
testb = 1
testc = 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment