kanade 5 years ago
parent d64dc6d1e6
commit f2e56efbb9

@ -0,0 +1,292 @@
// Code generated for package asset by go-bindata DO NOT EDIT. (@generated)
// sources:
// config/app.dev.ini
// config/app.ini
// config/app.test.ini
package asset
import (
"bytes"
"compress/gzip"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
"time"
)
func bindataRead(data []byte, name string) ([]byte, error) {
gz, err := gzip.NewReader(bytes.NewBuffer(data))
if err != nil {
return nil, fmt.Errorf("Read %q: %v", name, err)
}
var buf bytes.Buffer
_, err = io.Copy(&buf, gz)
clErr := gz.Close()
if err != nil {
return nil, fmt.Errorf("Read %q: %v", name, err)
}
if clErr != nil {
return nil, err
}
return buf.Bytes(), nil
}
type asset struct {
bytes []byte
info os.FileInfo
}
type bindataFileInfo struct {
name string
size int64
mode os.FileMode
modTime time.Time
}
// Name return file name
func (fi bindataFileInfo) Name() string {
return fi.name
}
// Size return file size
func (fi bindataFileInfo) Size() int64 {
return fi.size
}
// Mode return file mode
func (fi bindataFileInfo) Mode() os.FileMode {
return fi.mode
}
// Mode return file modify time
func (fi bindataFileInfo) ModTime() time.Time {
return fi.modTime
}
// IsDir return file whether a directory
func (fi bindataFileInfo) IsDir() bool {
return fi.mode&os.ModeDir != 0
}
// Sys return file is sys mode
func (fi bindataFileInfo) Sys() interface{} {
return nil
}
var _configAppDevIni = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x4c\x51\x5b\x4f\x1b\x3d\x14\x7c\xf7\x8f\xd9\xf8\xb6\xde\x18\xc9\x0f\x20\x10\x44\x41\x1f\xfa\x2a\x5a\x95\xa0\xa8\xf2\xe5\x2c\x71\xf7\x62\x63\x7b\x21\x9b\x5f\x5f\x65\x41\xa5\xf2\xcb\xf8\xcc\x8c\x3c\xe3\xe3\xc0\x4c\x2f\xaa\xa4\x09\x90\x76\x2e\x29\x5c\x2d\xe7\x62\x8d\xa5\x44\xe8\x79\x98\xf3\x6b\xbf\x47\xce\x1c\x42\x2e\x8a\xd0\x66\xa1\x09\x72\x26\x86\x54\x14\x63\x58\x20\x67\xa6\x0c\x49\xa5\x10\xca\x79\xae\x73\x7e\x0f\xc9\xa9\x02\xf9\x7c\x1f\xf5\x00\x1f\x38\x26\x68\xfd\x71\xc1\xbf\xd0\xa0\x8f\x1b\xd7\x83\x22\xf8\x0c\x1f\x22\x8c\xaa\xc6\x08\x3d\x17\x18\x2d\x8c\x65\x8f\xb2\xeb\x2e\x63\xdc\x38\x45\x38\xc6\x9c\x32\x29\x08\xf2\x0e\xc6\xe2\x5b\x0f\x49\x69\x37\xf8\xd1\xe7\x92\x74\x09\x09\xc1\x31\xfa\x04\x4a\x60\xd4\xc1\xac\x28\x01\xcd\x8c\xd1\xd2\x30\xd1\xe2\x46\x4a\xdc\xb2\x96\x32\x21\x29\x17\x2d\x76\xd2\x36\xd8\x69\xcc\x79\x03\xb5\xe5\x9c\x5b\x59\x53\x8e\x19\x97\x82\x18\x23\xac\x20\x28\x83\x4d\x50\x36\x4e\x5d\x6e\x37\xd7\x0f\xbb\x6f\xeb\x5d\x77\x79\xf7\xfb\x0a\xf2\x29\xbd\xbe\xc9\x27\x6f\x6e\x1e\x4f\xb7\xb7\xa7\xc7\xc3\xf8\x70\x95\x3f\xd5\x5b\x98\x95\xc1\x92\xb0\x78\xaf\x77\x9b\xe1\x3d\x12\x12\xae\xff\x23\xff\x3f\xdd\x75\xc7\xc9\x50\x2f\xb7\x37\x09\xe9\x8f\x46\xb4\xa6\x98\x92\x75\x5d\xff\xed\x5b\xf5\xfe\x0d\xf6\x4b\x7a\xa6\x1b\x6c\x24\xb4\x0d\x6f\x1b\xca\x1b\x59\x4b\xe6\x2c\x08\x20\x94\x62\x8c\x09\x41\x2e\x0c\xda\x8f\x8a\x10\x4a\x04\x5f\x8c\x71\xca\x87\x6a\x98\x5f\x6d\x1f\x26\x57\xd9\x30\x7c\x7d\x08\x46\x25\x81\x2e\xb3\x4a\x65\x88\x9f\xe3\x47\x3f\x80\x5a\x0b\x8e\xf1\xd7\xfb\xf9\x10\x52\xd9\xff\xeb\x0b\xe3\x22\xfc\xa1\x7b\xef\x14\x59\xa2\x59\x36\xce\xb7\xdd\xb5\x0d\x65\xad\x7f\x6e\xed\xcb\xf7\xdd\x3d\x20\xf4\x9c\xc0\x86\xd0\xed\xd1\x94\x7a\x75\x28\x25\xe6\x8b\xd5\xea\xbc\x65\x1d\x7d\x95\x60\x21\x2b\x3b\xae\x74\xf4\xab\x37\xf2\x27\x00\x00\xff\xff\x1f\xcf\xb1\x34\x71\x02\x00\x00")
func configAppDevIniBytes() ([]byte, error) {
return bindataRead(
_configAppDevIni,
"config/app.dev.ini",
)
}
func configAppDevIni() (*asset, error) {
bytes, err := configAppDevIniBytes()
if err != nil {
return nil, err
}
info := bindataFileInfo{name: "config/app.dev.ini", size: 625, mode: os.FileMode(420), modTime: time.Unix(1601436925, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
var _configAppIni = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x4a\x4c\x49\x29\xb2\x35\xd0\x03\x43\x2b\x0b\x03\x4b\x03\xae\xa2\xd2\xbc\xdc\xfc\x94\x54\x5b\x95\xea\xa0\x50\x3f\x5f\x7f\x17\xd7\x9a\x9a\x92\xd4\xe2\x92\x5a\x2e\xae\xe8\x82\xc4\xf4\xd4\x58\xae\xdc\xc4\x0a\x9f\xcc\xdc\xcc\x12\x5b\x43\x03\x03\xae\xdc\xcc\x3c\x28\x87\x2b\x25\x35\x2d\xb1\x34\xa7\x04\xca\x35\xe5\xe2\x8a\x2e\xc9\x2f\xc8\x4c\x8e\xe5\xca\xc8\x2f\x71\xce\x2f\xcd\x03\x69\xe0\x02\x04\x00\x00\xff\xff\x1b\x9a\x6c\x17\x70\x00\x00\x00")
func configAppIniBytes() ([]byte, error) {
return bindataRead(
_configAppIni,
"config/app.ini",
)
}
func configAppIni() (*asset, error) {
bytes, err := configAppIniBytes()
if err != nil {
return nil, err
}
info := bindataFileInfo{name: "config/app.ini", size: 112, mode: os.FileMode(420), modTime: time.Unix(1601451702, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
var _configAppTestIni = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x4c\x52\x5d\x4f\xdb\x30\x14\x7d\xf7\x8f\x49\xaf\x1d\xc7\xa9\x27\xf9\x01\x04\x2a\x55\xd9\xd0\xb6\x6e\x82\xa2\x0a\xf9\xe3\x86\x7a\x6d\x62\xd7\x76\xa0\xe5\xd7\x4f\x2d\x68\xec\xed\xca\x3e\xc7\x3e\x1f\xd7\xa1\x19\x9f\x55\x49\x23\x12\xf2\xd8\x1f\xf3\x7e\xb7\x26\xce\x6c\x42\x2e\x8a\x52\x56\x51\xc6\x2b\x06\x50\x31\x10\xc4\x99\x18\x52\x51\x75\x7d\x9e\xc7\x8c\x49\x39\xf3\x94\xd0\x86\xb0\x7d\xca\x63\xc4\x74\x82\xe8\x9c\x5f\x43\x72\x2a\xbb\xf1\xda\xc8\xaf\xcb\x9f\x7e\xbf\x79\xc5\xfb\x59\x3c\x68\x20\xce\x0c\xba\xc7\x4f\x1a\x89\x09\x3b\x7f\x50\x1f\x8f\xec\xfc\x0b\x3e\x91\x5e\x1f\xe6\x6e\x87\x8a\xc2\x69\xbc\x8b\x38\xa8\x06\x08\x79\x2c\x38\x58\x1c\xca\x9a\x64\xb7\xbd\x88\x71\xee\x14\xe5\x00\x9c\xd5\x52\x50\xe2\x1d\x0e\xc5\x77\x1e\x93\xd2\xae\xf7\x83\xcf\x25\xe9\x12\x12\xc1\x43\xf4\x09\x95\x00\xb2\xc5\xa3\x62\x14\x75\x6d\x8c\x96\xa6\x16\x1d\xb4\x52\x42\x57\x77\xac\x16\x92\x71\xd1\x81\x93\xb6\x05\xa7\x81\xf3\x16\x1b\xcb\x39\xb7\xb2\x61\x1c\x6a\x2e\x05\x35\x46\x58\x41\x49\x46\x9b\xb0\xcc\x9d\xba\x58\xcc\xaf\xee\x56\x3f\xa6\xab\xed\xc5\xcd\x9f\x4b\xcc\x6f\x69\xff\x22\x1f\xbc\xb9\x5e\xbe\xcd\x66\x6f\xcb\xcd\x70\x77\x99\x3f\xd0\x0b\x3c\x2a\x03\x92\xd6\xf1\x56\xaf\xe6\xfd\x6b\xa4\x34\x5c\x7d\xa3\xdf\x1f\x6e\xb6\x87\xd1\x30\x2f\x17\xd7\x89\xe8\x77\x47\xac\x61\xc0\xe8\xb4\x69\xfe\xf9\xad\x4e\xa9\xac\xcf\xea\x6b\xdd\x82\x91\xd8\xb5\xbc\x6b\x19\x6f\x65\x23\x6b\x67\x51\x20\x65\x0c\x00\x28\x25\x2e\xf4\xda\x0f\xa7\xe6\xa8\xe0\x67\x62\x1c\xf3\xa6\xea\x8f\x7b\xbb\x0b\xa3\xab\x6c\xe8\x3f\x03\x01\x52\x12\xea\x72\x54\xa9\xf4\xf1\xe3\x78\xe9\x7b\x54\x53\xc1\x01\x3e\xff\xcf\x9b\x90\xca\xfa\x7f\x5e\x18\xce\xc0\xdf\x7a\xe7\x9d\xa2\x67\x69\xb6\x1e\x8e\xb3\xed\x95\x0d\x65\xaa\xef\x17\xf6\xf9\xd7\xea\xf6\xb4\x51\xef\xc5\xae\xc9\x98\x76\x6a\x53\x4a\xcc\x5f\x26\x93\x82\xb9\xe8\xe8\xab\x84\xe7\xcb\xca\x0e\x13\x1d\xfd\xe4\x85\xfe\x0d\x00\x00\xff\xff\xfb\x7d\x44\xe7\x8c\x02\x00\x00")
func configAppTestIniBytes() ([]byte, error) {
return bindataRead(
_configAppTestIni,
"config/app.test.ini",
)
}
func configAppTestIni() (*asset, error) {
bytes, err := configAppTestIniBytes()
if err != nil {
return nil, err
}
info := bindataFileInfo{name: "config/app.test.ini", size: 652, mode: os.FileMode(420), modTime: time.Unix(1601451702, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
// Asset loads and returns the asset for the given name.
// It returns an error if the asset could not be found or
// could not be loaded.
func Asset(name string) ([]byte, error) {
cannonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := _bindata[cannonicalName]; ok {
a, err := f()
if err != nil {
return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err)
}
return a.bytes, nil
}
return nil, fmt.Errorf("Asset %s not found", name)
}
// MustAsset is like Asset but panics when Asset would return an error.
// It simplifies safe initialization of global variables.
func MustAsset(name string) []byte {
a, err := Asset(name)
if err != nil {
panic("asset: Asset(" + name + "): " + err.Error())
}
return a
}
// AssetInfo loads and returns the asset info for the given name.
// It returns an error if the asset could not be found or
// could not be loaded.
func AssetInfo(name string) (os.FileInfo, error) {
cannonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := _bindata[cannonicalName]; ok {
a, err := f()
if err != nil {
return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err)
}
return a.info, nil
}
return nil, fmt.Errorf("AssetInfo %s not found", name)
}
// AssetNames returns the names of the assets.
func AssetNames() []string {
names := make([]string, 0, len(_bindata))
for name := range _bindata {
names = append(names, name)
}
return names
}
// _bindata is a table, holding each asset generator, mapped to its name.
var _bindata = map[string]func() (*asset, error){
"config/app.dev.ini": configAppDevIni,
"config/app.ini": configAppIni,
"config/app.test.ini": configAppTestIni,
}
// AssetDir returns the file names below a certain
// directory embedded in the file by go-bindata.
// For example if you run go-bindata on data/... and data contains the
// following hierarchy:
// data/
// foo.txt
// img/
// a.png
// b.png
// then AssetDir("data") would return []string{"foo.txt", "img"}
// AssetDir("data/img") would return []string{"a.png", "b.png"}
// AssetDir("foo.txt") and AssetDir("notexist") would return an error
// AssetDir("") will return []string{"data"}.
func AssetDir(name string) ([]string, error) {
node := _bintree
if len(name) != 0 {
cannonicalName := strings.Replace(name, "\\", "/", -1)
pathList := strings.Split(cannonicalName, "/")
for _, p := range pathList {
node = node.Children[p]
if node == nil {
return nil, fmt.Errorf("Asset %s not found", name)
}
}
}
if node.Func != nil {
return nil, fmt.Errorf("Asset %s not found", name)
}
rv := make([]string, 0, len(node.Children))
for childName := range node.Children {
rv = append(rv, childName)
}
return rv, nil
}
type bintree struct {
Func func() (*asset, error)
Children map[string]*bintree
}
var _bintree = &bintree{nil, map[string]*bintree{
"config": &bintree{nil, map[string]*bintree{
"app.dev.ini": &bintree{configAppDevIni, map[string]*bintree{}},
"app.ini": &bintree{configAppIni, map[string]*bintree{}},
"app.test.ini": &bintree{configAppTestIni, map[string]*bintree{}},
}},
}}
// RestoreAsset restores an asset under the given directory
func RestoreAsset(dir, name string) error {
data, err := Asset(name)
if err != nil {
return err
}
info, err := AssetInfo(name)
if err != nil {
return err
}
err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
if err != nil {
return err
}
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
if err != nil {
return err
}
err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
if err != nil {
return err
}
return nil
}
// RestoreAssets restores an asset under the given directory recursively
func RestoreAssets(dir, name string) error {
children, err := AssetDir(name)
// File
if err != nil {
return RestoreAsset(dir, name)
}
// Dir
for _, child := range children {
err = RestoreAssets(dir, filepath.Join(name, child))
if err != nil {
return err
}
}
return nil
}
func _filePath(dir, name string) string {
cannonicalName := strings.Replace(name, "\\", "/", -1)
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
}

@ -2,6 +2,7 @@ package config
import (
"gopkg.in/ini.v1"
"live/app/lib/asset"
"log"
"os"
)
@ -22,10 +23,20 @@ func init() {
}
// 配置读取
Config.File, err = ini.Load(Config.WorkPath + "/config/app.ini")
Config.ValueMapper = ExpandValueEnv
if err != nil {
for _, s := range asset.AssetNames() {
if err := asset.RestoreAsset(Config.WorkPath, s); err != nil {
log.Fatal("释放资源出错", err)
return
}
}
Config.File, err = ini.Load(Config.WorkPath + "/config/app.ini")
if err != nil {
log.Fatal("配置文件读取失败err:", err)
return
}
}
Config.ValueMapper = ExpandValueEnv
Config.RUNMODE = Config.Section("").Key("runmode").String()
if Config.RUNMODE != "" {
Config.Append(Config.WorkPath + "/config/app." + Config.RUNMODE + ".ini")

Loading…
Cancel
Save