gkit

package module
v0.0.0-...-684de13 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2020 License: MIT Imports: 9 Imported by: 0

README

go 工具集

ini_parser

解析ini配置文件, 文件格式形如:

[section1]
    option1 = xxxx
    option2 = xxxx
# start with '#' is a comment
; start with ';' is a comment too
[section2]
    option3 = xxxxx

解析出的结果放到IniConfig中,其结构为map[string]Section, 可以通过Get方法获取某个section. 也可以通过GetOption方法获取某个配置项

Section数据结构map[string]string, 可以通过Get来获取某些option配置

json_parser

根据json文件路径解析json数据

collection

Set

Set数据结构

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseJSON

func ParseJSON(filePath string, data interface{}) interface{}

ParseJSON 解析配置文件

Types

type IniConfig

type IniConfig map[string]Section

IniConfig 配置

func ParseIni

func ParseIni(path string) (IniConfig, error)

ParseIni parse config data from a ini file. file like: [section1]

option1 = xxxx
option2 = xxxx

# start with '#' is a comment ; start with ';' is a comment too [section2]

option3 = xxxxx
...

func (IniConfig) Get

func (c IniConfig) Get(key string) Section

Get 获取配置section

func (IniConfig) GetOption

func (c IniConfig) GetOption(sKey string, optKey string) string

GetOption 从config中获取某个配置

type Section

type Section map[string]string

Section 配置文件中某section配置项

func (Section) Get

func (s Section) Get(key string) string

Get 从section获取某个配置值

type Set

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

Set 自定义Set类型

func NewSet

func NewSet() *Set

NewSet create an new set

func (*Set) Add

func (s *Set) Add(key interface{})

Add add an item into this set

func (*Set) AddSet

func (s *Set) AddSet(set Set)

AddSet add a set into this one

func (*Set) IsEmpty

func (s *Set) IsEmpty() bool

IsEmpty whether an empty set

func (*Set) ToString

func (s *Set) ToString() string

ToString to string

Jump to

Keyboard shortcuts

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