kproperties

package
v1.0.4-Realize Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

* 包kproperties包含了对Properties文件的封装及描述

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Properties

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

对properties格式文件的数据结构体

func New

func New(propertiesFilePath string) (*Properties, error)

返回由propertiesFilePath路径的properties文件解析后的properties实例

当读取配置文件失败的时候意味着这是一个完全无效且可能会造成后续程序异常的操作,抛出error。

读取的配置文件中如果存在“\r\n”或“\n”,抛出error。

读取的配置文件中如果发生没有key的情况,抛出error。

func (*Properties) Each

func (slf *Properties) Each(eachFunc func(key string, value string))

func (*Properties) GetBool

func (slf *Properties) GetBool(key string) bool

func (*Properties) GetFloat32

func (slf *Properties) GetFloat32(key string) (float32, error)

func (*Properties) GetFloat64

func (slf *Properties) GetFloat64(key string) (float64, error)

func (*Properties) GetInt

func (slf *Properties) GetInt(key string) (int, error)

func (*Properties) GetInt16

func (slf *Properties) GetInt16(key string) (int16, error)

func (*Properties) GetInt32

func (slf *Properties) GetInt32(key string) (int32, error)

func (*Properties) GetInt64

func (slf *Properties) GetInt64(key string) (int64, error)

func (*Properties) GetInt8

func (slf *Properties) GetInt8(key string) (int8, error)

func (*Properties) GetInterface

func (slf *Properties) GetInterface(key string) interface{}

func (*Properties) GetString

func (slf *Properties) GetString(key string) string

func (*Properties) GetUint

func (slf *Properties) GetUint(key string) (uint, error)

func (*Properties) GetUint16

func (slf *Properties) GetUint16(key string) (uint16, error)

func (*Properties) GetUint32

func (slf *Properties) GetUint32(key string) (uint32, error)

func (*Properties) GetUint64

func (slf *Properties) GetUint64(key string) (uint64, error)

func (*Properties) GetUint8

func (slf *Properties) GetUint8(key string) (uint8, error)

func (*Properties) HasKey

func (slf *Properties) HasKey(key string) bool

type PropertiesInterface

type PropertiesInterface interface {

	// 返回这个properties中key对应的value转换为string类型后的值
	GetString(key string) string

	// 返回这个properties中key对应的value转换为int类型后的值
	//
	// 默认的实现中为了方便查看,允许在value中填写“123,456,789”这种格式。
	// 默认的实现中会自动将value中的空格和“,”分隔符全部排除。
	GetInt(key string) (int, error)

	// 返回这个properties中key对应的value转换为int8类型后的值
	//
	// 默认的实现中为了方便查看,允许在value中填写“123,456,789”这种格式。
	// 默认的实现中会自动将value中的空格和“,”分隔符全部排除。
	GetInt8(key string) (int8, error)

	// 返回这个properties中key对应的value转换为int16类型后的值
	//
	// 默认的实现中为了方便查看,允许在value中填写“123,456,789”这种格式。
	// 默认的实现中会自动将value中的空格和“,”分隔符全部排除。
	GetInt16(key string) (int16, error)

	// 返回这个properties中key对应的value转换为int32类型后的值
	//
	// 默认的实现中为了方便查看,允许在value中填写“123,456,789”这种格式。
	// 默认的实现中会自动将value中的空格和“,”分隔符全部排除。
	GetInt32(key string) (int32, error)

	// 返回这个properties中key对应的value转换为int64类型后的值
	//
	// 默认的实现中为了方便查看,允许在value中填写“123,456,789”这种格式。
	// 默认的实现中会自动将value中的空格和“,”分隔符全部排除。
	GetInt64(key string) (int64, error)

	// 返回这个properties中key对应的value转换为uint类型后的值
	//
	// 默认的实现中为了方便查看,允许在value中填写“123,456,789”这种格式。
	// 默认的实现中会自动将value中的空格和“,”分隔符全部排除。
	GetUint(key string) (uint, error)

	// 返回这个properties中key对应的value转换为uint8类型后的值
	//
	// 默认的实现中为了方便查看,允许在value中填写“123,456,789”这种格式。
	// 默认的实现中会自动将value中的空格和“,”分隔符全部排除。
	GetUint8(key string) (uint8, error)

	// 返回这个properties中key对应的value转换为uint16类型后的值
	//
	// 默认的实现中为了方便查看,允许在value中填写“123,456,789”这种格式。
	// 默认的实现中会自动将value中的空格和“,”分隔符全部排除。
	GetUint16(key string) (uint16, error)

	// 返回这个properties中key对应的value转换为uint32类型后的值
	//
	// 默认的实现中为了方便查看,允许在value中填写“123,456,789”这种格式。
	// 默认的实现中会自动将value中的空格和“,”分隔符全部排除。
	GetUint32(key string) (uint32, error)

	// 返回这个properties中key对应的value转换为uint64类型后的值
	//
	// 默认的实现中为了方便查看,允许在value中填写“123,456,789”这种格式。
	// 默认的实现中会自动将value中的空格和“,”分隔符全部排除。
	GetUint64(key string) (uint64, error)

	// 返回这个properties中key对应的value转换为bool类型后的值
	//
	// 默认实现中"1", "true", "ok", "yes", "sure", "affirm", "has", "success"均为true,反之为false
	GetBool(key string) bool

	// 返回这个properties中key对应的value转换为interface类型后的值
	GetInterface(key string) interface{}

	// 返回这个properties中key对应的value转换为float32类型后的值
	//
	// 默认的实现中为了方便查看,允许在value中填写“123,456,789.123”这种格式。
	// 默认的实现中会自动将value中的空格和“,”分隔符全部排除。
	GetFloat32(key string) (float32, error)

	// 返回这个properties中key对应的value转换为float64类型后的值
	//
	// 默认的实现中为了方便查看,允许在value中填写“123,456,789.123”这种格式。
	// 默认的实现中会自动将value中的空格和“,”分隔符全部排除。
	GetFloat64(key string) (float64, error)

	// 遍历所有的kv对
	Each(eachFunc func(key string, value string))

	// 返回是否存在Key
	HasKey(key string) bool
}

表示了一个完整的Properties需要实现的函数。

Jump to

Keyboard shortcuts

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