go-gitconfig
is a pacakge to use gitconfig
values in Golang.
Sometimes you want to extract username or its email address implicitly in your tool.
Now most of developer use git
, so we can use its configuration variables. go-gitconfig
is for that.
If you want to use git user name defined in ~/.gitconfig
:
username, err := gitconfig.Username()
Or git user email defined in ~/.gitconfig
:
email, err := gitconfig.Email()
Or, if you want to extract origin url of current project (from .git/config
):
url, err := gitconfig.OriginURL()
You can also extract value by key:
editor, err := gitconfig.Global("core.editor")
remote, err := gitconfig.Local("branch.master.remote")
See more details in document at https://godoc.org/github.com/tcnksm/go-gitconfig.
To install, use go get
:
$ go get -d github.com/tcnksm/go-gitconfig
These packages have many features to use git from golang. go-gitconfig
is very simple alternative and focus to extract information from gitconfig. go-gitconfig
is used in tcnksm/ghr.
- Fork (https://github.com/tcnksm/go-gitconfig/fork)
- Create a feature branch
- Commit your changes
- Rebase your local changes against the master branch
- Run test suite with the
go test ./...
command and confirm that it passes - Run
gofmt -s
- Create new Pull Request