Skip to content

ccthomas/goconfig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goconfig

Golang Configuration Package to assist with developing simple micro services.

Requirements

  • Golang verison 1.6

Usage

Envrionemnt Variables

Variable Notes
GOCONFIG_DB_HOST Database Host. Example: postgres
GOCONFIG_DB_NAME Database Name
GOCONFIG_DB_PASSWORD Database Password
GOCONFIG_DB_PORT Database Port
GOCONFIG_DB_SSLMODE Should Database use SSLMode
GOCONFIG_DB_USER Database User
GOCONFIG_LOG_FILE_NAME Name of log file.
GOCONFIG_LOG_LEVEL Log levels can be found here.
GOCONFIG_LOG_TO_TERMINAL If true , logs will be printed to the terminal

Logger

import "github.com/CCThomas/goconfig/pkg/loggers"
loggers.ConfigureLogrus()
GOCONFIG_LOG_FILE_NAME=my-service.log
GOCONFIG_LOG_LEVEL=debug
GOCONFIG_LOG_TO_TERMINAL=true

Database

Currently Postgres is the only supported database

import "github.com/CCThomas/goconfig/pkg/databases"
databases.ConfigureGorm()
database.DB.Create(&myModel)
GOCONFIG_DB_HOST=localhost
GOCONFIG_DB_USER=myuser
GOCONFIG_DB_PASSWORD=mypassword
GOCONFIG_DB_NAME=dbname
GOCONFIG_DB_PORT=5434
GOCONFIG_DB_SSLMODE=disable

Web

Get Json

import (
  "github.com/CCThomas/goconfig/pkg/web"
  "github.com/gin-gonic/gin"
)
// c *gin.Context
requestJson, err := web.GetJson(c)
if err != nil {
  // Response has already been set.
  return
}

Third Party

About

Golang Configuration Package to assist with developing simple micro services.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages