MCPcopy Create free account
hub / github.com/devfeel/dottask / lookupFile

Function lookupFile

config.go:106–127  ·  view source on GitHub ↗
(configFile string)

Source from the content-addressed store, hash-verified

104}
105
106func 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
129func fileExists(filename string) bool {
130 _, err := os.Stat(filename)

Callers 3

XmlConfigHandlerFunction · 0.85
JsonConfigHandlerFunction · 0.85
YamlConfigHandlerFunction · 0.85

Calls 2

fileExistsFunction · 0.85
getCurrentDirectoryFunction · 0.85

Tested by

no test coverage detected