title: Not able to read TOML file using Go with BurntSushi library
body: <p>I am using the BurntSushi library to load a TOML configuration file in my GO application. I have followed the instructions on the library to write the structs and the configuration toml file itself. I am running into some trouble, and I cant seem to find the source of my issues.</p>
  
  <p>Here are the details:</p>
  
  <p>Structs:</p>
  
  <pre><code>package main
  
  
  //ConfigurationParameters provides the struct to hold configuration parameters from config file
  type ConfigurationParameters struct {
      Title string
      //serviceDiscovery captures configuration parameters needed for service discovery registration with Consul
      ServiceDiscovery ConsulConf `toml:"ServiceDiscovery"`
      //metadataReporting captures which metadata to be registered with service into consul for use during discovery
      MetadataReporting MetaDataConf `toml:"MetadataReporting"`
      //awsTagsToLabels captures the aws tags that should be added to reported metrics as Labels
      AwsTagsToLabels LabelConf `toml:"AwsTagsToLabels"`
      //collectors captures the list of collectors to use
      Collectors CollectorConf `toml:"Collectors"`
      //service captures agent related configurations
      Service ServiceConf `toml:"Service"`
  }
  
  //ConsulConf captures configuration parameters needed for service discovery registration with Consul
  type ConsulConf struct {
      enabled    bool
      endpoint   string
      port       int
      datacenter string
      serviceID  string
  }
  //MetaDataConf captures which metadata to be registered with service into consul for use during discovery
      type MetaDataConf struct {
          enabled   bool
          awsregion string
      }
  //LabelConf captures the aws tags that should be added to reported metrics as Labels
  type LabelConf struct {
      enabled       bool
      refreshPeriod int
  }
  
  //CollectorConf captures the list of collectors to use
  type CollectorConf struct {
      goCollectionEnabled       bool
      exporterCollectionEnabled bool
      wmiCollectionEnabled      bool
      agentCollectionEnabled    bool
      enabledCollectors         string
      metricMap                 []MetricMap
  }
  
  //MetricMap captures a mapping between one or more WMI metrics and the name it should be reported with
  type MetricMap struct {
      wmiMetricName  []string
      exportName     string
      dropMetric     bool
      computedMetric bool
      computeLogic   string
  }
  
  //ServiceConf captures agent related configurations
  type ServiceConf struct {
      listenIP           string
      listenPort         int
      metricPath         string
      collectionInterval int
      serviceName        string
  }
  </code></pre>
  
  <p>and the configuration toml file:</p>
  
  <pre><code>Title = "WMI Exporter Configuration"
  
  [ServiceDiscovery]
      enabled = true
      endpoint = "my.consul.server"
      port = 5500
      datacenter = "ucm-west"
      serviceID = "ucm.agent.wmiExporter"
  
  [MetadataReporting]
      enabled = true
      awsregion = "us-west-2"
  
  [AwsTagsToLabels]
      enabled = true
      refreshPeriod = 3600
  
  [Collectors]
      goCollectionEnabled = true
      exporterCollectionEnabled = true
      wmiCollectionEnabled = true
      agentCollectionEnabled = false
      enabledCollectors   = "cpu,os"
      [Collectors.MetricMap.0]
          wmiMetricName = ["test"]
          exportName = "export_test"
  
  [Service]
      listenPort =  9103
      metricPath = "/metrics"
      collectionInterval = 60
      serviceName = "wmi_exporter"
  </code></pre>
  
  <p>And the code that reads the config file:</p>
  
  <pre><code>// InitializeFromConfig reads configuration parameters from configuration file and initializes this service
  func InitializeFromConfig(configfile string) ConfigurationParameters {
      conf := ConfigurationParameters{}
  
      if configfile == "" {
          return conf
      }
  
      _, err := toml.DecodeFile(configfile, &amp;conf)
      if err != nil {
          log.Fatalf("Cannot parse configuration file at %s. Error=%s", configfile, err)
      }
      //at this point, conf is a fully loaded configuration now; now initialize everything from conf
      return conf
  }
  </code></pre>
  
  <p>The issue I am facing is that only the value for the Title attribute gets mapped into the GO struct members. All of the other configs stay unmapped. Looking at all of the examples on github for BurntSushi and <a href="https://stackoverflow.com/questions/34307488/go-how-to-use-toml-files">(Go) How to use toml files?</a>, I cant see any difference from what I am currently doing in code.</p>
  
  <p>I also used the tomlv validator from the BurntSushi package to look at the types from the TOML file, and I believe they look correct.</p>
  
  <p>Datatypes: </p>
  
  <pre><code>Title                                             String
  ServiceDiscovery                                  Hash
      ServiceDiscovery.enabled                      Bool
      ServiceDiscovery.endpoint                     String
      ServiceDiscovery.port                         Integer
      ServiceDiscovery.datacenter                   String
      ServiceDiscovery.serviceID                    String
  MetadataReporting                                 Hash
      MetadataReporting.enabled                     Bool
      MetadataReporting.awsregion                   String
  AwsTagsToLabels                                   Hash
      AwsTagsToLabels.enabled                       Bool
      AwsTagsToLabels.refreshPeriod                 Integer
  Collectors                                        Hash
      Collectors.goCollectionEnabled                Bool
      Collectors.exporterCollectionEnabled          Bool
      Collectors.wmiCollectionEnabled               Bool
      Collectors.agentCollectionEnabled             Bool
      Collectors.enabledCollectors                  String
          Collectors.MetricMap.0                    Hash
              Collectors.MetricMap.0.wmiMetricName  Array
              Collectors.MetricMap.0.exportName     String
  Service                                           Hash
      Service.listenPort                            Integer
      Service.metricPath                            String
      Service.collectionInterval                    Integer
      Service.serviceName                           String
  </code></pre>
  
  <p>I tried debugging into the BurntSushi package code, but it was not very helpful (the Delve debugger was not able to display some of the variables in that package, and seemed to randomly jump between the lines in that package).</p>
  
  <p>Any help or pointers on what I could be doing wrong?</p>
  
  <p>Thanks.</p>