1
This commit is contained in:
parent
0067fe79b2
commit
b50a0152e1
49
init.go
49
init.go
@ -1,4 +1,53 @@
|
|||||||
package q5
|
package q5
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"fmt"
|
||||||
|
"bufio"
|
||||||
|
)
|
||||||
|
|
||||||
|
var optDebug = ""
|
||||||
|
var _optDebug = false
|
||||||
|
var _optTimeZone int64 = 8
|
||||||
|
var q5JsonConfData = ""
|
||||||
|
var q5JsonConf *XObject
|
||||||
|
var initLines []string
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
initLines = make([]string, 0)
|
||||||
|
if optDebug != "" {
|
||||||
|
_optDebug = true
|
||||||
|
}
|
||||||
|
initLines = append(initLines, fmt.Sprintf("optDebug %s _optDebug:%t", optDebug, _optDebug))
|
||||||
|
confName := "q5.json"
|
||||||
|
if Debug() {
|
||||||
|
confName = "q5.debug.json"
|
||||||
|
}
|
||||||
|
if f, err := os.Open(confName); err == nil {
|
||||||
|
defer f.Close()
|
||||||
|
q5JsonConfData, _ = bufio.NewReader(f).ReadString(0)
|
||||||
|
q5JsonConf = NewXoFromJsonStr(q5JsonConfData)
|
||||||
|
if q5JsonConf.HasKey("timeZone") {
|
||||||
|
_optTimeZone = q5JsonConf.At("timeZone").AsXValue().GetInt64()
|
||||||
|
if _optTimeZone < 1 || _optTimeZone > 24 {
|
||||||
|
panic(confName +
|
||||||
|
" timeZone error val:" +
|
||||||
|
NewXInt64(_optTimeZone).GetString())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
initLines = append(initLines, fmt.Sprintf("%s data:%s", confName, q5JsonConfData))
|
||||||
|
initLines = append(initLines, fmt.Sprintf("%s json:%s", confName, q5JsonConf.ToJsonStr()))
|
||||||
|
} else {
|
||||||
|
initLines = append(initLines, fmt.Sprintf("%s not found", confName))
|
||||||
|
}
|
||||||
|
initLines = append(initLines, fmt.Sprintf("_optTimeZone:%d", _optTimeZone))
|
||||||
|
if Debug() {
|
||||||
|
for _, val := range initLines {
|
||||||
|
fmt.Println(val)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetInitLogs() []string {
|
||||||
|
return initLines
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,12 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func Debug() bool {
|
||||||
|
return _optDebug
|
||||||
|
}
|
||||||
|
|
||||||
func GetTimeZone() int64 {
|
func GetTimeZone() int64 {
|
||||||
return 0
|
return _optTimeZone
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetDaySeconds(seconds int64) int64 {
|
func GetDaySeconds(seconds int64) int64 {
|
||||||
|
@ -31,6 +31,12 @@ func NewXInt32(val int32) *XValue {
|
|||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewXInt64(val int64) *XValue {
|
||||||
|
p := new(XValue)
|
||||||
|
p.SetInt64(val)
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
|
||||||
func NewXString(val string) *XValue {
|
func NewXString(val string) *XValue {
|
||||||
p := new(XValue)
|
p := new(XValue)
|
||||||
p.SetString(val)
|
p.SetString(val)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user