Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/chen-keinan/go-simple-config
- Owner: chen-keinan
- License: apache-2.0
- Created: 2021-05-26T13:34:25.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-12-11T12:29:52.000Z (about 1 year ago)
- Last Synced: 2024-06-21T14:17:49.493Z (8 months ago)
- Topics: configuration, opensource
- Language: Go
- Homepage:
- Size: 151 KB
- Stars: 3
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
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)
[![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)
# 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 mainimport (
"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"))
}
```