config

package module
v0.0.0-...-8d428bf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2021 License: MIT Imports: 3 Imported by: 1

README

github.com/cagox/config

This simple package is the result of my search to find a simple standardize way to handle configuration files for my Go project.

It operations by loading the contents of a JSON file into a struct that you define. See github.com/cagox/config/main for an example of how this works.

The steps to use this package amount to the following:

  1. Create your own local configuration struct (or use ours if you think it works).
  2. Embed our ConfigurationStruct in your struct.
  3. Create a JSON configuration file for your project, and set an environmental variable to point to it's location.
  4. Call LoadConfigs()
  5. Reference the configuration struct for configuration variables.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfigs

func LoadConfigs(config interface{}, envVariable string)

LoadConfigs loads a configuration file and stuffs it into the interface named config.

Types

type ConfigurationStruct

type ConfigurationStruct struct {
	//Basic Site Configuration
	Hosts        string
	StaticPath   string
	TemplateRoot string
	//Basic Security Configuration
	AdminToken        string
	MinimumNameLength int
	MinPasswordLength int
	EncKey            string
	AuthKey           string
	CookieName        string

	//Database Configuration
	DatabaseName      string
	DatabaseUserName  string
	DatabasePassword  string
	DatabaseServerURL string
	DatabaseOptions   string
}

* ConfigurationStruct holds some generic configuration information but is * primarily there to hang the related methods off of.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL