I've been trying reading configuration by viper, while it always panic nil pointer reference(i've been set the config path and config name).
Then i tried to make a execution point on it and it tells me :
unreadable: could not read string at 0x8 due to Only part of a ReadProcessMemory or WriteProcessMemory request was completed.
Here is the config directory: Config directory
This is how i set the path:enter image description here
I'm almost crazy of it!!! It has been bothers me for 2 days (plz excuse me of lacking the experience of golang... I'm a new learner and thanks for your help very, very much!)
I tried the following structure:
With the following lines in the file config.go:
And my configuration file contains:
In this case, my version is nil. But, if I set
v.AddConfigPath("./Config")
Then my version is 1.0.0.
Your path depends on where is your
main.go
and not where is yourconfig.go
.If you still have problems, it could also be due to bad rights on the file. You can still try to do a
chmod 777 [your configuration file]
to check if you code didn't need more right to read the file.