Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

applicationName? #4

Open
puzanov opened this issue Mar 26, 2018 · 1 comment
Open

applicationName? #4

puzanov opened this issue Mar 26, 2018 · 1 comment

Comments

@puzanov
Copy link

puzanov commented Mar 26, 2018

Why do we need applicationName? If we do not provide it, the lib can use local config path, for example store.Load("./config.yaml", &config)

@karanveersp
Copy link

This response is years late, but since I just discovered this package and started reading the source, I can answer your question.
The path parameter of the Save and Load functions is supposed to be a relative path, not an absolute path.

This is because internally, the os specific path builder function pieces together the absolute path from three things - the os specific configuration directory, applicationName , and finally the path.

This is evident in this code:

// buildPlatformPath builds a platform-dependent path for relative path given.
func buildPlatformPath(path string) string {
	if runtime.GOOS == "windows" {
		return fmt.Sprintf("%s\\%s\\%s", os.Getenv("APPDATA"),
			applicationName,
			path)
	}
       //...
}

So to use this library, you should call Init with your applicationName and then the path needs to be the relative path to this applicationName directory inside the os specific configuration directory.

Hope that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants