M
M
memba2016-11-29 11:21:36
go
memba, 2016-11-29 11:21:36

How to fix the absolute path to the settings files?

Hey!
In the vast majority, the application needs configs, which are usually stored in text files. And if you are making a normal application, then you need to access them no matter where your binary is located.
The train of my thoughts:
Downloaded sorstsy anywhere, where it is convenient.
Compiled sorts anywhere, even in $HOME, even on the desktop.
Configs and other auxiliary files remained in the sorts, which is quite logical.
We register the path to the binary in $ PATH.
Now if we have a relative path `ReadFile("./config.conf")` in our application, then wherever I call '$> myapp', the application will assume that `config.conf` is in the directory in which I am making a challenge. Those. the meaning of $PATH is lost.
And I cannot specify absolute paths, because I don't want to bind sorts to $GOPATH. And code generation is powerless here. And every time I do not want to set the path to sorts through flags. And asking people to create some kind of system variable with a path to sorts is not good.
It turns out that you need to make the installer and collect the configs somewhere in $HOME.
Seems like a necessary opportunity. Why would he not know where the binary was compiled from.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question