Skip to content
master
Switch branches/tags
Code
This branch is 29 commits ahead, 1 commit behind muja:master.
Contribute

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

goconfig

Travis Build Status

Table of contents

  1. Introduction
  2. Usage
  3. Contributing
  4. Reporting bugs

1. Introduction

This project parses config files that have the same syntax as gitconfig files. It understands multiple values configuration, and can parse included configs by include.path directions (includeIf.*.path configuration is not supported yet).

It has no knowledge of git-specific keys and as such, does not provide any convenience methods like config.GetUserName(). For these, look into go-gitconfig

Most of the code was copied and translated to Go from git/config.c

2. Usage

To load specific git config file and inherit global and system git config, using:

package main

import (
	"fmt"
	"log"

	"github.com/jiangxin/goconfig"
)

func main() {
	cfg, err := goconfig.LoadAll("")
	if err != nil {
		log.Fatal(err)
	}
	if cfg == nil {
		log.Fatal("cfg is nil")
	}

	fmt.Printf(cfg.Get("user.name"))
}

As an example, there is a full functional git config to read/write git config file implemented by goconfig, see:

cmd/goconfig/main.go

3. Contributing

Contributions are welcome! Fork -> Push -> Pull request.

4. Bug report / suggestions

Just create an issue! I will try to reply as soon as possible.

About

.gitconfig syntax parser

Resources

License

Packages

No packages published