How can import a file realtive to the revel basefolder in revel framework. Currently I do the following to get hold of some config values.
file, err := ioutil.ReadFile("conf/config.conf")
...
This results in my server only working if i stand in the app directory when starting revel with
revel run myapp
Is there a way to access the base folder?
I use this method: In conf/app.conf add a line with the configuration path of this way:
projectname.path = "/foldersnames/"
and in the controller Write a method like this:
You can build a helper with this code and take configurations variables from all applications.
You must call of this way:
There are exported global variables in the
revel
package, you can use any of these:If it is empty for you, that is most likely because you started your app from the base folder.
Note that these paths are set by the
Init(mode, importPath, srcPath string)
function. It's documentation states:Also check out: how to reference a relative file from code and tests