(configFile string)
| 104 | } |
| 105 | |
| 106 | func lookupFile(configFile string) (realFile string, exists bool) { |
| 107 | //add default file lookup |
| 108 | //1、按绝对路径检查 |
| 109 | //2、尝试在当前进程根目录下寻找 |
| 110 | //3、尝试在当前进程根目录/config/ 下寻找 |
| 111 | //fixed for (#3 当使用json配置的时候,运行会抛出panic) |
| 112 | realFile = configFile |
| 113 | exists = true |
| 114 | if !fileExists(realFile) { |
| 115 | realFile = getCurrentDirectory() + "/" + configFile |
| 116 | exists = false |
| 117 | } |
| 118 | if !exists && !fileExists(realFile) { |
| 119 | realFile = getCurrentDirectory() + "/config/" + configFile |
| 120 | } else { |
| 121 | exists = true |
| 122 | } |
| 123 | if !exists && fileExists(realFile) { |
| 124 | exists = true |
| 125 | } |
| 126 | return realFile, exists |
| 127 | } |
| 128 | |
| 129 | func fileExists(filename string) bool { |
| 130 | _, err := os.Stat(filename) |
no test coverage detected