Provides a simple path resolving mechanism relative to a defined basedir
Installation
go get github.com/wiggisser/pathresolver
Examples
package main
import (
pr "github.com/wiggisser/pathresolver"
)
func main() {
//initializes the pathresolver to "~/.fooapp/" on unix-based systems and "%HOMEDIR%\AppData\Roaming\fooapp" on windows-based systems
err := pr.Init(".fooapp", "AppData\\Roaming\\fooapp")
//resolves to "~/.fooapp" and "%HOMEDIR%\AppData\Roaming\fooapp" on unix and windows respectively
p, err := pr.Path("")
//resolves the filename to "~/.fooapp/foo.bar" and "%HOMEDIR%\AppData\Roaming\fooapp\foo.bar" on unix and windows respectively
p, err := pr.Path("foo.bar")
}
Init initializes the pathresolver with a basedir for the respective system.
If only one of the parameters is set, it is used of all systems
If both parameters are set, the basedirectory is set according to the current system
If the given paths are relative, they are set relative to the users homedir (~ and %HOMEDIR% respectively)