config

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

README

配置工具

gotool 提供基于 .ini 文件的配置工具,基于 gopkg.in/ini.v1

配置文件 ./config.ini

请在项目根目录下创建 ./config.ini 并添加自己的配置, 如 :

# 运行模式
RunMode=dev

[Cache]
# 支持 redis 和 map
Type=map
Prefix=gotool_

# Redis 缓存配置
[RedisCache]
Host=127.0.0.1
Port=6379
Password=
DefaultDB=0

获取配置数据

package main

import (
	"fmt"

	"github.com/cnlesscode/gotool/config"
)

func main() {
	println("welcome to use gotool ...")
	host := config.Ini.Section("RedisCache").Key("Host")
	fmt.Printf("host: %v\n", host)
	port, _ := config.Ini.Section("RedisCache").Key("Port").Int()
	fmt.Printf("host: %v\n", port)
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Ini *ini.File

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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