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.
63 lines
1.1 KiB
Go
63 lines
1.1 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"`
|
|
}
|
|
|
|
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/prac/svc/icsbc/conf/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
|
|
}
|