<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          goconfGo 的配置解析模塊

          聯(lián)合創(chuàng)作 · 2023-09-28 16:02

          goconf 是 Go 語言用來解析 ini 配置文件的模塊,示例代碼:

          package main                                                                   
          
          import (                                                                       
              "fmt"                                                                      
              "github.com/Terry-Mao/goconf"                                              
          )                                                                              
          
          type TestConfig struct {
              ID     int           `goconf:"core:id"`
              Col    string        `goconf:"core:col"`
              Ignore int           `goconf:"-"`
              Arr    []string      `goconf:"core:arr:,"`
              Test   time.Duration `goconf:"core:t_1:time"`
              Buf    int           `goconf:"core:buf:memory"`
              M      map[int]string`goconf:"core?,"`
          }
          
          func main() {                                                                  
              conf := goconf.New()                                                       
              if err := conf.Parse("./examples/conf_test.txt"); err != nil {             
                  panic(err)                                                             
              }                                                                          
              core := conf.Get("core")                                                   
              if core == nil {                                                           
                  panic("no core section")                                               
              }                                                                          
              id, err := core.Int("id")                                                  
              if err != nil {                                                            
                  panic(err)                                                             
              }                                                                          
              fmt.Println(id)                                                            
              tf := &TestConfig{}
              if err := conf.Unmarshall(tf); err != nil {
                  panic(err)
              }
              fmt.Println(tf.ID)
          }
          瀏覽 22
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          編輯 分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  天天天日夜夜夜操 | 国产草视频在线播放 | 國產精品77777777777 | 国产午夜激情 | 操视频网站|