Skip to content

Instantly share code, notes, and snippets.

Created May 19, 2020
What would you like to do?
package config
import (
type configList struct {
APIKey string
APISecret string
LogFile string
DefaultRunMode string
// Config is Implementation of ConfigList
var Config configList
func init() {
cfg, err := ini.Load("config.ini")
if err != nil {
log.Printf("Failed to read file: %v", err)
Config = configList{
APIKey: cfg.Section("api").Key("api_key").String(),
APISecret: cfg.Section("api").Key("api_secret").String(),
LogFile: cfg.Section("app").Key("log_file").String(),
ProductCode: cfg.Section("app").Key("default_run_mode").String(),
package main
import (
func main() {
// print config.ini values
fmt.Println("APIKey: ", config.Config.APIKey)
fmt.Println("APISecret: ", config.Config.APISecret)
fmt.Println("LogFile: ", config.Config.LogFile)
fmt.Println("DefaultRunMode: ", config.Config.DefaultRunMode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment