Skip to content

eaciit/appconfig

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

config

Simple config information for Go application saved in json format

Usage

Load from repo

go get -u github.com/juragan360/config

then import it on any Go app

import "github.com/juragan360/config"

Initiate config

Initiate config from specific location

if e := config.SetConfigFile("/tmp/app1/config.json"); e!= nil {
	panic(e.Error())
}

or Initiate config without specify file, then it will create config.json file on same directory of executable

if e := config.SetConfigFile(""); e!= nil {
	panic(e.Error())
}

Set a config value

config.Set("FullName", "Arief Darmawan")
if e := config.Write(); e != nil {
	panic(e.Error())
}

Get a config value

s := config.Get("FullName").(string)
if s != "Arief Darmawan" {
	panic("Unable to read value. Expected 'Arief Darmawan' got '" + s + "'")
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages