package main

//BY: 29295842@qq.com
//这个有一定问题   如果配置信息里有中文就不行
//[Server] ;MYSQL配置
//Server=localhost   ;主机
//golang 读取 ini配置信息
//http://www.widuu.com/archives/02/961.html
import (
  "fmt"
  "github.com/widuu/goini"
  //"runtime"
  //"time"
)

func Read_ini_string(file_data string, KEY1 string, KEY2 string) string {
  conf := goini.SetConfig(file_data) //goini.SetConfig(filepath) 其中filepath是你ini 配置文件的所在位置
  return conf.GetValue(KEY1, KEY2)   //database是你的[section],username是你要获取值的key名称
}
func main() {
  fmt.Println(Read_ini_string("server.ini", "Server", "Username1"))

//conf := goini.SetConfig("server.ini")           //goini.SetConfig(filepath) 其中filepath是你ini 配置文件的所在位置
  //username := conf.GetValue("Server", "Username") //database是你的[section],username是你要获取值的key名称
  //fmt.Println(username)
  /*for {
    time.Sleep(1 * time.Second)
    runtime.Gosched()
  }  */
}

 
标签: <无>
 

代码片段(1)[全屏查看所有代码]

1. [文件] main.go ~ 1KB     下载(2)     跳至 [1] [全屏预览]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package main
 
//BY: 29295842@qq.com
//这个有一定问题   如果配置信息里有中文就不行
//[Server] ;MYSQL配置
//Server=localhost   ;主机
//golang 读取 ini配置信息
//http://www.widuu.com/archives/02/961.html
import (
    "fmt"
    "github.com/widuu/goini"
    //"runtime"
    //"time"
)
 
func Read_ini_string(file_data string, KEY1 string, KEY2 string) string {
    conf := goini.SetConfig(file_data) //goini.SetConfig(filepath) 其中filepath是你ini 配置文件的所在位置
    return conf.GetValue(KEY1, KEY2)   //database是你的[section],username是你要获取值的key名称
}
func main() {
    fmt.Println(Read_ini_string("server.ini", "Server", "Username1"))
 
    //conf := goini.SetConfig("server.ini")           //goini.SetConfig(filepath) 其中filepath是你ini 配置文件的所在位置
    //username := conf.GetValue("Server", "Username") //database是你的[section],username是你要获取值的key名称
    //fmt.Println(username)
    /*for {
        time.Sleep(1 * time.Second)
        runtime.Gosched()
    }  */

最新文章

  1. 安装nodejs express框架时express命令行无效
  2. [react native] react-native-tab-navigator在子Component中隐藏
  3. MYSQL:使用\G参数改变输出结果集的显示方式
  4. c++ poco库https调用
  5. eclipse设置字体、背景(豆绿)色、自动提示
  6. 元素设置position:fixed属性后IE下宽度无法100%延伸
  7. 让Grub 2来拯救你的 bootloader
  8. 洛谷P1983 车站分级
  9. 单片机usb转串口的时灵时不灵的解答
  10. apache点NET环境
  11. python包管理-distutils,setuptools,pip,virtualenv等介绍
  12. sublime Text3配置及快捷键、插件推荐总结
  13. 关于导出oracle多个表的建表语句DLL,生成.sql语句。
  14. DNF(一.YUM已死,DNF代之)
  15. web2py官方文档翻译01
  16. Android Bluetooth Stack: Bluedroid(五岁以下儿童):The analysis of A2DP Source
  17. 使用filter方法过滤集合元素
  18. Ubuntu 自动选择最快的镜像源
  19. Linux colrm命令详解
  20. linux基本格式和常用目录命令一

热门文章

  1. 为什么我markdown里的数学公式全崩了???
  2. LINUXE下执行php 定时任务
  3. kafka manager遇到的一些问题
  4. windows下Mysql5.7表名不区分大小写问题
  5. JS 判断是否为null
  6. Spring MVC 常用注解 和session界面渲染取值
  7. PHP面试 MySQL创建高性能索引考点
  8. A + B Problem II HDU - 1002
  9. Python文章导航
  10. Java web后台插入数据库中文乱码问题解决