如何从代码和testing引用相关文件
我需要从patients.go引用patients.json ,这里是文件夹结构: 

如果我做:
 filepath.Abs("../../conf/patients.json") 
 它适用于go test ./... revel run go test ./...但失败的revel run 
如果我做:
 filepath.Abs("conf/patients.json") 
完全相反的事情发生(狂欢是好的,但testing失败)。
有没有办法正确引用该文件,使其既可以用于testing和正常的程序运行?
相对path总是被解释/parsing为一个基本path: 当前或工作目录 – 因此总会有其局限性。
如果你能一直照顾正确的工作目录,你可以继续使用相对path。
我会build议不要依赖工作目录,而是明确指定的基本path。 这可能有一个硬编码在你的应用程序(也可能是工作目录)的默认值,你应该提供几种方法来覆盖它的值。
推荐的方法来覆盖“相对”path所针对的基本path:
-  命令行标志(见flag包)
-  环境variables(参见os.Getenv())
-   (修复命名)configuration文件在用户的主目录(请参阅os/user/User和os/user/Current())
 一旦你有了基本path,你可以通过join基本path和相对path来获得完整的path。 您可以使用path.Join()或filepath.Join() ,例如: 
 // Get base path, from any or from the combination of the above mentioned solutions base := "/var/myapp" // Relative path, resource to read/write from: relf := "conf/patients.json" // Full path that identifies the resource: full := filepath.Join(base, relf) // full will be "/var/myapp/conf/patients.json" 
我从来没有用过Revel自己,但以下看起来对我有帮助:
http://revel.github.io/docs/godoc/revel.html
-  revel.BasePath
-  revel.AppPath