Search Gear Notes Search Gear Notes

Go, Spew, Hopwatch, toml-go

Debugging github.com/davecgh/go-spew github.com/emicklei/hopwatch

hopwatch uses go-spew Dump and Dumpf

Both are good and seem useful. http://ernestmicklei.com/2012/12/14/hopwatch-a-debugging-tool-for-go/

go-toml-config does not work and the documentation is wrong. Persistently get ‘panic: myconfig.conf is not a valid TOML file. See https://github.com/mojombo/toml' even when it’s the test file from https://github.com/mojombo/toml

package main

import “github.com/stvp/go-toml-config”

var ( title= config.String(“title”, “Unknown”) name = config.String(“owner.name”, “”) git = config.String(“owner.GitHub”, “”) bio = config.String(“owner.bio”, “”)

enabled = config.Bool("owner.enabled", false)
connection_max = config.Int("owner.connection_max", 0)

)

func main() {

if err := config.Parse("myconfig.conf"); err != nil {
    panic(err)
}   

}

viper over a TOML file gives go run searchgear.go (viper.UnsupportedConfigError) Unsupported Config Type "" (string) ""

adding filename extension to be the language ie myconfig.conf becomes myconfig.toml has an effect but still empty variables

IT SEEMS WE HAVE A WINNER!

github.com/laurent22/toml-go

package main

import ( “github.com/laurent22/toml-go” “github.com/davecgh/go-spew/spew” )

var parser toml.Parser

func main() {

doc := parser.ParseFile("myconfig.toml")
spew.Dump(doc.GetString("owner.name"))

}

go run searchgear.go (string) (len=18) “Tom Preston-Werner”

https://github.com/toml-lang/toml/blob/master/tests/example.toml