I have a project with next structure:
|_main.go
|_config
|_config.go
|_config_test.go
|_config.json
I'm having next code line in config.go
:
file, _ := os.Open("config/config.json")
When I'm executing method contained this code line from main.go
all is working. But when I'm trying to execute this method from config_test.go
it produces error:
open config/config.json: no such file or directory
As I understood it is a working directory issue because I'm launching same code with relative path from different directories. How can I fix this problem without using full path in config.go
?