// config.ini

[app]
server.port = 8080
name = resk
enabled = false
time = 10s


;我是一个注释
#mysql数据库配置
[mysql]
driverName = mysql
address = 192.168.232.175:3306
username = po
password = 111111
database = po
// main.go

package main

import (
	"fmt"
	"github.com/tietang/props/ini"
	"github.com/tietang/props/kvs"
	"time"
)

func main() {
	file := kvs.GetCurrentFilePath("config.ini", 1)
	conf := ini.NewIniFileConfigSource(file)
	port := conf.GetIntDefault("app.server.port", 18080)
	fmt.Println(port)
	fmt.Println(conf.GetDefault("app.name", "unknow"))
	fmt.Println(conf.GetBoolDefault("app.enabled", false))
	fmt.Println(conf.GetDurationDefault("app.time", time.Second))
}

相关文章:

  • 2022-12-23
  • 2022-03-07
  • 2022-12-23
  • 2021-08-31
  • 2021-12-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-23
  • 2021-12-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案