欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

go讀取ini文件并修改

go 讀取 ini文件 并修改

安裝

官方網(wǎng)站
https://ini.unknwon.io/docs/intro/getting_started
go get gopkg.in/ini.v1

配置

tmp
    my.ini
    main.go
my.ini

# possible values : production, development
app_mode = development

[paths]
# Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used)
data = /home/git/grafana

[server]
# Protocol (http or https)
protocol = http

# The http port  to use
http_port = 9999

# Redirect to correct domain if host header does not match domain
# Prevents DNS rebinding attacks
enforce_domain = true
main.go

package main

import (
    "fmt"
    "os"

    "gopkg.in/ini.v1"
)

func main() {

    dir, _ := os.Getwd()
    fmt.Println(dir)
    path := dir + "\\src\\test\\tmp\\"   // windows下的路徑  需要注意修改一下   默認(rèn)是gopath
    path_name := path + "my.ini"
    cfg, err := ini.Load(path_name)
    if err != nil {
        fmt.Printf("Fail to read file: %v", err)
        os.Exit(1)
    }

    // 典型讀取操作,默認(rèn)分區(qū)可以使用空字符串表示
    fmt.Println("App Mode:", cfg.Section("").Key("app_mode").String())
    fmt.Println("Data Path:", cfg.Section("paths").Key("data").String())

    // 我們可以做一些候選值限制的操作
    fmt.Println("Server Protocol:",
        cfg.Section("server").Key("protocol").In("http", []string{"http", "https"}))
    // 如果讀取的值不在候選列表內(nèi),則會(huì)回退使用提供的默認(rèn)值
    fmt.Println("Email Protocol:",
        cfg.Section("server").Key("protocol").In("smtp", []string{"imap", "smtp"}))

    // 試一試自動(dòng)類型轉(zhuǎn)換
    fmt.Printf("Port Number: (%[1]T) %[1]d\n", cfg.Section("server").Key("http_port").MustInt(9999))
    fmt.Printf("Enforce Domain: (%[1]T) %[1]v\n", cfg.Section("server").Key("enforce_domain").MustBool(false))

    // 差不多了,修改某個(gè)值然后進(jìn)行保存
    cfg.Section("").Key("app_mode").SetValue("production")
    cfg.SaveTo(path+"my.ini.local")
}
注意路徑

結(jié)果

App Mode: development
Data Path: /home/git/grafana
Server Protocol: http
Email Protocol: smtp
Port Number: (int) 9999
Enforce Domain: (bool) true

分享題目:go讀取ini文件并修改
新聞來源:http://chinadenli.net/article40/ppsoeo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供做網(wǎng)站、網(wǎng)站排名、外貿(mào)網(wǎng)站建設(shè)、建站公司、全網(wǎng)營(yíng)銷推廣、商城網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站建設(shè)網(wǎng)站維護(hù)公司
91免费一区二区三区| 成人区人妻精品一区二区三区| 免费大片黄在线观看日本| 热久久这里只有精品视频| 日韩欧美一区二区亚洲| 国产精品欧美一区两区| 中文字幕中文字幕在线十八区| 日本精品中文字幕人妻| 激情中文字幕在线观看 | 亚洲精品中文字幕欧美| 五月天综合网五月天综合网| 国产精品一区二区视频| 99久久国产综合精品二区| 国产午夜福利一区二区| 夫妻性生活黄色录像视频| 婷婷开心五月亚洲综合| 国产在线小视频你懂的| 99久久精品一区二区国产| 亚洲国产精品无遮挡羞羞| 国产日产欧美精品视频| 国产成人亚洲欧美二区综| 东京热加勒比一区二区三区| 日韩欧美中文字幕人妻| 欧美日韩最近中国黄片| 日韩精品人妻少妇一区二区| 午夜精品久久久免费视频| 人妻巨大乳一二三区麻豆| 国产福利在线播放麻豆| 好吊妞视频只有这里有精品| 久久精品国产熟女精品| 日韩欧美一区二区黄色| 免费特黄一级一区二区三区| 欧美整片精品日韩综合| 激情内射日本一区二区三区| 高清国产日韩欧美熟女| 欧美精品亚洲精品日韩精品| 午夜视频免费观看成人| 亚洲国产精品国自产拍社区| 视频在线免费观看你懂的| 日韩精品少妇人妻一区二区| 国产精品视频一区麻豆专区|