Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/chen-keinan/go-simple-config

open source for accessing and storing configuration
https://github.com/chen-keinan/go-simple-config

configuration opensource

Last synced: 4 months ago
JSON representation

open source for accessing and storing configuration

Awesome Lists containing this project

README

        

[![Go Report Card](https://goreportcard.com/badge/github.com/chen-keinan/go-simple-config)](https://goreportcard.com/report/github.com/chen-keinan/go-simple-config)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/chen-keinan/go-simple-config/blob/master/LICENSE)
test coverage badge
[![Gitter](https://badges.gitter.im/beacon-sec/community.svg)](https://gitter.im/beacon-sec/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)


simple-config.png logo

# go-simple-config

Go Simple config is an open source configuration lib for storing and accessing configuration data with minimal
dependencies

* [Installation](#installation)
* [Supported Configuration Files](#supported-configuration-files)
* [Usage](#usage)

## Installation

```shell
go get github.com/chen-keinan/go-simple-config
```

## Supported configuration files:

- yaml
- json
- properties
- environment variables
- ini

## Usage

### json config example:

```json
{
"SERVER": {
"host": "127.0.0.1",
"port": "8080"
}
```

### yaml config example:

```yaml
---
SERVER:
host: 127.0.0.1
port: '8080'
```

### properties config example:

```json
SERVER.host=127.0.0.1
SERVER.port=8080
```

### env. variable config example:

```shell
export SERVER_HOST="127.0.0.1"
export SERVER_PORT="8080"
```

### Full example :

```go
package main

import (
"fmt"
"github.com/chen-keinan/go-simple-config/simple"
"os"
)

func main() {
c := simple.New()
err := c.Load("config.json")

if err != nil {
fmt.Print(err.Error())
os.Exit(1)
}
fmt.Print(c.GetStringValue("SERVER.host"))
}
```