nafi

package module
v0.0.0-...-7b98de1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2025 License: MIT Imports: 7 Imported by: 0

README

NAFI: Not Another Form Interpreter

NAFI is a simple configuration file parser for Go, supporting multiple formats including .conf, .ini, .json, and .yaml. It provides a quick interface for loading and accessing configuration values from files, making it easy to manage application settings regardless of the file format.

Installation

Add to your go.mod:

go get github.com/Snowzei/NAFI

Import in your code:

import "github.com/Snowzei/NAFI"

Usage

Load a Configuration File
config, err := nafi.ConfigParser("path/to/config.json", "json")
if err != nil {
    panic(err)
}
Retrieve Values

For flat key-value formats (.conf):

val, err := config.Get("keyname")

For sectioned formats (.ini):

val, err := config.Get("section.keyname")

For nested formats (.json, .yaml):

val, err := config.Get("parent.child.keyname")
Supported File Types
  • conf: Simple key-value pairs, one per line (key = value)
  • ini: INI files with sections and keys
  • json: JSON files with nested objects
  • yaml: YAML files with nested structures

API Reference

ConfigParser
func ConfigParser(filepath string, fileType string) (ConfigParserObj, error)

Reads and parses a configuration file, returning a ConfigParserObj.

ConfigParserObj.Get
func (c *ConfigParserObj) Get(key string) (string, error)

Retrieves the value for the specified key, supporting dot notation for nested/sectioned formats.

Example

config.yaml
server:
  host: "localhost"
  port: 8080
main.go
config, err := nafi.ConfigParser("config.yaml", "yaml")
if err != nil {
    panic(err)
}

host, _ := config.Get("server.host") // returns "localhost"
port, _ := config.Get("server.port") // returns "8080"

License

MIT


NAFI: Not Another Form Interpreter – Unified, simple config parsing for Go.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigParser

func ConfigParser(filepath string, fileType string) (configParserObj, error)

Reads a filepath on the disk and parses it, returning a ConfigParserObj object.

Supported file types:

"conf", "ini", "json", "yaml"

Types

This section is empty.

Jump to

Keyboard shortcuts

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