genius

package module
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: Apache-2.0 Imports: 10 Imported by: 5

README

genius

genius config

feature

  • 大小写不忽略, 保持差异
  • 支持几乎所有的配置文件类型
  • 支持 get array
  • 支持 set array
  • 支持 append array

quick start

go get github.com/jaronnie/genius@latest
package main

import (
	"fmt"
	"github.com/jaronnie/genius"
)

func main() {
	g, err := genius.NewFromRawJSON([]byte(`
{
    "name":"jaronnie",
    "age": 23,
    "skills": ["golang", "python", "c"]
}`))
	if err != nil {
		panic(err)
	}

	fmt.Println(g.Get("name"))
	fmt.Println(g.Get("skills"))
	fmt.Println(g.Get("skills.0"))
	_ = g.Set("skills.0", "go")
	fmt.Println(g.Get("skills.0"))
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Genius

type Genius struct {
	// contains filtered or unexported fields
}

func New

func New(source map[string]any, opts ...Opt) *Genius

func NewFromRawJSON

func NewFromRawJSON(source []byte, opts ...Opt) (*Genius, error)

func NewFromToml added in v0.3.0

func NewFromToml(source []byte, opts ...Opt) (*Genius, error)

func NewFromType added in v0.4.2

func NewFromType(source []byte, configType string, opts ...Opt) (*Genius, error)

func NewFromYaml added in v0.4.1

func NewFromYaml(source []byte, opts ...Opt) (*Genius, error)

func (*Genius) Append

func (g *Genius) Append(key string, values ...any) error

Append append data to a slice

func (*Genius) Del added in v0.6.0

func (g *Genius) Del(key string)

func (*Genius) EncodeToJSON added in v0.4.0

func (g *Genius) EncodeToJSON() ([]byte, error)

func (*Genius) EncodeToPrettyJSON added in v0.5.2

func (g *Genius) EncodeToPrettyJSON() ([]byte, error)

func (*Genius) EncodeToToml added in v0.3.1

func (g *Genius) EncodeToToml() ([]byte, error)

func (*Genius) EncodeToType added in v0.4.2

func (g *Genius) EncodeToType(configType string) ([]byte, error)

func (*Genius) EncodeToYaml added in v0.4.0

func (g *Genius) EncodeToYaml() ([]byte, error)

func (*Genius) Get

func (g *Genius) Get(key string) any

func (*Genius) GetAllKeys

func (g *Genius) GetAllKeys() []string

func (*Genius) GetAllSettings

func (g *Genius) GetAllSettings() map[string]any

func (*Genius) GetOuterKeys

func (g *Genius) GetOuterKeys(key string) []string

GetOuterKeys Experiment Feature

func (*Genius) GetTopLevelKeys added in v0.6.1

func (g *Genius) GetTopLevelKeys() []string

func (*Genius) IsIndexPath

func (g *Genius) IsIndexPath(key string) bool

func (*Genius) IsSet

func (g *Genius) IsSet(key string) bool

func (*Genius) Set

func (g *Genius) Set(key string, value any) error

func (*Genius) Sub

func (g *Genius) Sub(key string) *Genius

type Opt

type Opt func(*Option)

func WithDelimiter

func WithDelimiter(delimiter string) Opt

type Option

type Option struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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