You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
1.5 KiB
Go
75 lines
1.5 KiB
Go
package icsconf
|
|
|
|
import (
|
|
"encoding/xml"
|
|
"fmt"
|
|
"os"
|
|
"sync"
|
|
)
|
|
|
|
type AppInfo struct {
|
|
XMLName xml.Name `xml:"AppInfo"`
|
|
Speech Speech `xml:"Speech"`
|
|
Directories Directories `xml:"Directories"`
|
|
STT STTConf `xml:"STT"`
|
|
Urls Urls `xml:"Urls"`
|
|
}
|
|
|
|
type Urls struct {
|
|
FailedDataListUrl string `xml:"FailedDataListUrl"`
|
|
NockChiServer NockChiServer `xml:"NockChiServer"`
|
|
TAUrl string `xml:"TAUrl"`
|
|
}
|
|
|
|
type NockChiServer struct {
|
|
Port string `xml:"port,attr"`
|
|
SrcIP string `xml:"srcIP,attr"`
|
|
}
|
|
|
|
type Speech struct {
|
|
Package string `xml:"Package"`
|
|
ProtoPackage string `xml:"ProtoPackage"`
|
|
}
|
|
|
|
type Directories struct {
|
|
PCMDirectory string `xml:"PCMDirectory"`
|
|
WAVDirectory string `xml:"WAVDirectory"`
|
|
LOGDirectory string `xml:"LOGDirectory"`
|
|
RecDirectory string `xml:"RecDirectory"`
|
|
}
|
|
|
|
type STTConf struct {
|
|
Value string `xml:"value,attr"`
|
|
Name string `xml:"name,attr"`
|
|
Port string `xml:"port,attr"`
|
|
SrcIP string `xml:"srcIP,attr"`
|
|
}
|
|
|
|
var (
|
|
once sync.Once
|
|
appInfo AppInfo
|
|
)
|
|
|
|
func loadConfig() {
|
|
file, err := os.Open("/home/jiyoungc/svc/icsbc/config/Appinfo.xml")
|
|
if err != nil {
|
|
fmt.Println("failed to open config file: ", err)
|
|
return
|
|
}
|
|
defer file.Close()
|
|
|
|
if err := xml.NewDecoder(file).Decode(&appInfo); err != nil {
|
|
fmt.Println("failed to decode XML: ", err)
|
|
return
|
|
}
|
|
}
|
|
|
|
func initConfig() {
|
|
once.Do(loadConfig)
|
|
}
|
|
|
|
func Getconfig() AppInfo {
|
|
initConfig()
|
|
return appInfo
|
|
}
|