Read Mercurial configuration (hg config
) values in Go.
Useful for finding out config values such as ui.username
.
go get gopkg.in/nishanths/go-hgconfig.v1
Import it as:
import gopkg.in/nishanths/go-hgconfig.v1
and refer to it as hgconfig
.
Tests can be found in go_hgconfig_test.go
. To run tests, install ginkgo and gomega, then run:
go test
package main
import (
"fmt"
"gopkg.in/nishanths/go-hgconfig.v1"
)
func main() {
value, _ := hgconfig.Get("ui.username")
fmt.Println(value)
}
An example can also be found at example/main.go
, and can be run using go run example/main.go
.
Get lets you read a hg config
value by name.
value, _ := hgconfig.Get("merge-tools.editmerge.premerge")
Username is a convenience function for getting the config value for ui.username
. This is the same as calling hgconfig.Get("ui.username")
.
username, _ := hgconfig.Username()
Pull requests for new features are welcome!
go-hgconfig is licensed under the MIT License