1 Star 1 Fork 0

水不要鱼 / props

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

⚙ props

Go Doc License Coverage Test

props 是一个用于解析 properties 配置文件的库,可以应用于所有的 GoLang 应用程序中。

Read me in English

☁️ 功能特性

  • 解析 properties 配置,提供多种类型转换方式,方便配置的类型转换

🔨 安装方式

$ go get -u github.com/FishGoddess/props

💡 参考案例

package main

import (
	"fmt"

	"github.com/FishGoddess/props"
)

func main() {
	// Load properties from a file.
	properties, err := props.LoadFile("load.properties")
	if err != nil {
		panic(err)
	}

	// Get one key from properties and covert it into a integer.
	fmt.Println(properties.Get("key1"))
	fmt.Println(properties.Get("key1").Int())

	// List all entries in properties.
	// Returns false if you want to continue listing.
	properties.List(func(key string, value props.Value) (finished bool) {
		fmt.Println(key, value)
		return false
	})

	// Use StoreFile to store a props to a file.
	// What's more, we provide StoreMap and StoreWriter to store a props to map and writer.
	err = props.StoreFile(properties, "store.properties")
	if err != nil {
		panic(err)
	}
}

👀 贡献者

如果您觉得 props 缺少您需要的功能,请不要犹豫,马上参与进来,发起一个 issue

The MIT License (MIT) Copyright (c) 2024 FishGoddess Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

一个用于解析 properties 配置文件的库 - A properties lib for Go applications 展开 收起
Go 等 2 种语言
MIT
取消

发行版 (3)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
Go
1
https://gitee.com/FishGoddess/props.git
git@gitee.com:FishGoddess/props.git
FishGoddess
props
props
main

搜索帮助