コード例 #1
0
ファイル: config_gen.go プロジェクト: gophergala2016/source
func Load() {
	mode := foundation.Mode()
	names := []string{
		"app.tml",
		"dev/api.tml",
		"dev/database.tml",
		"dev/view.tml",
		"test/api.tml",
		"test/database.tml",
		"test/view.tml",
	}
	for _, name := range names {
		dir, _ := filepath.Split(name)
		if len(dir) > 0 && !strings.HasPrefix(dir, mode) {
			continue
		}
		b := MustAsset(filepath.Join(configDir, name))
		err := config.Unmarshal(b)
		if err != nil {
			panic(err)
		}
		foundation.Printf("Load Config File: %s", name)
	}
	config.Mode = mode
}
コード例 #2
0
ファイル: init.go プロジェクト: gophergala2016/source
func Init(appName, port string) {
	AppName = appName
	basePath = foundation.BasePath
	internalPath = filepath.Join(basePath, "internal")
	ViewsPath = filepath.Join(internalPath, "views")

	paths := [][]string{
		{"    BasePath", foundation.BasePath},
		{"   ViewsPath", ViewsPath},
	}
	foundation.DebugPrintf("[%s] Running %s in %s mode\n", AppName, AppName, foundation.Mode())
	foundation.DebugPrintf("[%s] Listening and serving HTTP on %s\n", AppName, port)
	for _, v := range paths {
		foundation.DebugPrintf("[%s] %s = %s\n", AppName, v[0], v[1])
	}
}