go-mycms-configfile

module
v1.0.2-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2023 License: MIT

README

Go MyCMS ConfigFile

This package is an utility to read config files

The project configuration can be stored on the following file types:

  • JSON
  • XML
  • TOML
  • YAML

Versions

Current version is v1.0.2-alpha

Install

In your go project, run the following command

go get github.com/Lucas-Palomo/go-mycms-configfile@latest

Parse Example

This is toml configuration file.

[database]
host="localhost"
port=3306
username="root"
password="toor"

Calling toml configuration is easy, see the bellow code:


package main

import (
	ConfigFile "github.com/Lucas-Palomo/go-mycms-configfile/configfile"
)

type Conf struct {
	DB DatabaseConf `toml:"database"`
}

type DatabaseConf struct {
	Host     string `toml:"host"`
	Port     int    `toml:"port"`
	Username string `toml:"username"`
	Password string `toml:"password"`
}

func main() {
	conf := Conf{}
	ConfigFile.ReadFile("/home/user/config.toml", &conf, ConfigFile.TOML)
	// Now conf has all populated values
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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