please i need help in reading from an env.json file. Anytime i run my code i always get this error
Error reading config file, Config File "env" Not Found in "[/Users/franklynomonade/go/src/bitbucket.org/core_backend/cmd/server/bitbucket.org/core_backend/pkg/app/config]"
"/Users/franklynomonade/go/src/bitbucket.org/core_backend/cmd/server"
is the path where my main.go file is in, while "bitbucket.org/core_backend/pkg/app/config"
is the path where the env.json file is located.
I believe the path where the env.json file should be read is "bitbucket.org/core_backend/pkg/app/config"
and not "/Users/franklynomonade/go/src/bitbucket.org/core_backend/cmd/server/bitbucket.org/core_backend/pkg/app/config"
I am using github.com/spf13/viper
package to read the env.json file.
func LoadConfig() {
viper.AddConfigPath(myPath)
viper.SetConfigName("env")
viper.SetConfigType("json")
// searches for config file in given paths and read it
if err := viper.ReadInConfig(); err != nil {
log.Fatalf("error reading config file: %s", err)
}
// confirm which config file is used
log.Printf("Using s: %s\n", viper.ConfigFileUsed()
}
Any idea on how i can fix this?