jiangxin / goconfig

.gitconfig syntax parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

License:Other


Languages

Language:Go 99.4%Language:Makefile 0.6%