revel

how to reference a relative file from code and tests

有些话、适合烂在心里 提交于 2019-11-26 02:25:29
问题 I need to reference patients.json from patients.go , here\'s the folder structure: If I do: filepath.Abs(\"../../conf/patients.json\") it works for go test ./... but fails for revel run If I do: filepath.Abs(\"conf/patients.json\") the exact opposite happens (revel is fine but tests fail). Is there a way to correctly reference the file so that it works both for tests and normal program run? 回答1: Relative paths are always interpreted / resolved to a base path: the current or working directory