EExcel 丞燕快速查詢2

EExcel 丞燕快速查詢2
EExcel 丞燕快速查詢2 https://sandk.ffbizs.com/

config env get name and value

use github.com/spf13/viper Get env data

config.go


type urls struct {
    Demo1 string `mapstructure:"demo1"`
    Demo2 string `mapstructure:"demo2"`
}

type NotifyHttps struct {
    Name    string  `mapstructure:"name"`
    Token   string  `mapstructure:"token"`
    Urls    urls    `mapstructure:"urls"`
}

type env struct {
    NotifyHttp   NotifyHttps `mapstructure:"notify_https"`
}
.env


notify_https:
  name: order_comfire
  token: 123456abcdef
  urls:
    demo1: localhost:8888
    demo2: localhost:8443
notify.go


refUrls := reflect.ValueOf(config.Env.NotifyHttps.Urls)
urlNum := refUrls.NumField()

for i := 0; i < urlNum; i++ {
  url := refUrls.Field(i).String()
  if url != "" {
    // notify url 
    // record refUrls.Type().Field(i).Name be notify.
  }
}