Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/timvaillancourt/go-mongodb-config
A package for reading/writing MongoDB yaml-based configurations
https://github.com/timvaillancourt/go-mongodb-config
golang-structs mongodb mongodb-config
Last synced: about 1 month ago
JSON representation
A package for reading/writing MongoDB yaml-based configurations
- Host: GitHub
- URL: https://github.com/timvaillancourt/go-mongodb-config
- Owner: timvaillancourt
- License: apache-2.0
- Created: 2016-12-23T13:50:44.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-09-03T11:41:19.000Z (about 6 years ago)
- Last Synced: 2024-06-21T17:58:35.072Z (5 months ago)
- Topics: golang-structs, mongodb, mongodb-config
- Language: Go
- Homepage:
- Size: 32.2 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-mongodb-config
[![](https://godoc.org/github.com/timvaillancourt/go-mongodb-config?status.svg)](http://godoc.org/github.com/timvaillancourt/go-mongodb-config)
[![Build Status](https://travis-ci.org/timvaillancourt/go-mongodb-config.svg?branch=master)](https://travis-ci.org/timvaillancourt/go-mongodb-config)
[![Go Report Card](https://goreportcard.com/badge/github.com/timvaillancourt/go-mongodb-config)](https://goreportcard.com/report/github.com/timvaillancourt/go-mongodb-config)
[![codecov](https://codecov.io/gh/timvaillancourt/go-mongodb-config/branch/master/graph/badge.svg)](https://codecov.io/gh/timvaillancourt/go-mongodb-config)A package for reading/writing MongoDB yaml-based configurations
## Docs
- [github.com/timvaillancourt/go-mongodb-config/config](https://godoc.org/github.com/timvaillancourt/go-mongodb-config/config)## Usage
Create 'Config' struct from file (YAML-based only):
```
import (
mongodb_config "github.com/timvaillancourt/go-mongodb-config/config"
)func main() {
config, err := mongodb_config.Load("/etc/mongod.conf")
if err != nil {
panic(err)
}
...
}
```Create 'Config' struct from uri:
```
import (
mongodb_config "github.com/timvaillancourt/go-mongodb-config/config"
)func main() {
config, err := mongodb_config.LoadUri("http://example.com/etc/mongod.conf")
if err != nil {
panic(err)
}
...
}
```Write 'Config' struct to file:
```
import (
mongodb_config "github.com/timvaillancourt/go-mongodb-config/config"
)
func main() {
config := mongodb_config.New()
...
err := config.Write("/etc/mongod.conf")
if err != nil {
panic(err)
}
}
```