conf

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 6 Imported by: 1

README

goconf

This is a preferences API inspired by that of fyne

Create this basically because, the fyne configuration api saves its files in [configuration path]/fyne/appID/config.json and with this case, I want it to be saved in [configuration path]/appID/config.json without any trace of that framework, since it is a GUI framework, and I would like to be able to apply that to a CLI application

Usage/Examples

package main

import (
 "fmt"

 conf "github.com/Tom5521/goconf"
)

func main() {
 settings, err := conf.New("myapp")
 if err != nil {
  panic(err)
 }
 settings.SetString("c1", "value1")

 fmt.Println(settings.String("c1"))
}

Installation

Install my-project with go get

go get -u github.com/Tom5521/goconf@latest

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Preferences

type Preferences interface {
	Read(key string) any
	Set(key string, value any)
	// Bool looks up a bool value for the key
	Bool(key string) bool

	// SetBool saves a bool value for the given key
	SetBool(key string, value bool)

	// BoolList looks up a list of bool values for the key
	BoolList(key string) []bool

	// SetBoolList saves a list of bool values for the given key
	SetBoolList(key string, value []bool)

	// Float looks up a float64 value for the key
	Float(key string) float64

	// SetFloat saves a float64 value for the given key
	SetFloat(key string, value float64)

	// FloatList looks up a list of float64 values for the key
	FloatList(key string) []float64

	// SetFloatList saves a list of float64 values for the given key
	SetFloatList(key string, value []float64)

	// Int looks up an integer value for the key
	Int(key string) int

	// SetInt saves an integer value for the given key
	SetInt(key string, value int)

	// IntList looks up a list of int values for the key
	IntList(key string) []int

	// SetIntList saves a list of string values for the given key
	SetIntList(key string, value []int)

	// String looks up a string value for the key
	String(key string) string

	// SetString saves a string value for the given key
	SetString(key string, value string)

	// StringList looks up a list of string values for the key
	StringList(key string) []string

	// SetStringList saves a list of string values for the given key
	SetStringList(key string, value []string)

	// RemoveValue removes a value for the given key
	RemoveValue(key string)
}

Preferences describes the ways that an app can save and load user preferences

func New

func New(id string) (Preferences, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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