Exemplo n.º 1
0
// InitializeTest is to run common initial code for test
func InitializeTest(prefix string) {
	flag.Parse()

	//log
	lg.InitializeLog(uint8(*LogFlg), lg.LogOff, 0, prefix, "/var/log/go/test.log")

	//-v : to show Logs.(-test.v=true)
	if o.FindParam("-test.v") {
		lg.Debug("This test can show log in detail.")
	}

	//crypt
	enc.NewCryptDefault()

	//conf
	if *ConfFile == "" {
		*ConfFile = os.Getenv("GOPATH") + "/src/github.com/hiromaily/golibs/config/settings.toml"
	}
	conf.New(*ConfFile, true)

	//json
	if *JSONFile == "" {
		//default
		*JSONFile = os.Getenv("GOPATH") + "/src/github.com/hiromaily/golibs/testdata/json/teachers.json"
	}

	//bench
	if o.FindParam("-test.bench") {
		lg.Debug("This is bench test.")
		BenchFlg = true
	}
}
Exemplo n.º 2
0
func init() {
	lg.InitializeLog(lg.DebugStatus, lg.LogOff, 99, "[BookingTeacher]", "/var/log/go/book.log")

	flag.Usage = func() {
		fmt.Fprint(os.Stderr, fmt.Sprintf(usage, os.Args[0]))
	}

	//command-line
	flag.Parse()

	//signal (Debug)
	go signal.StartSignal()

	//cipher
	_, err := enc.NewCryptDefault()
	if err != nil {
		panic(err)
	}

	//config
	conf.New(*tomlPath, true)
	//conf.Cipher()
}