store icon indicating copy to clipboard operation
store copied to clipboard

applicationName?

Open puzanov opened this issue 6 years ago • 1 comments

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)

puzanov avatar Mar 26 '18 18:03 puzanov

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!

karanveersp avatar Apr 29 '23 07:04 karanveersp