pathresolver

package module
v0.0.0-...-881d39a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2019 License: MIT Imports: 5 Imported by: 0

README

Pathresolver

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")
}

Documentation

Overview

Package pathresolver provides a simple path resolving mechanism relative to a defined basedir

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(unix string, windows string) error

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)

func Path

func Path(subpath string) (string, error)

Path resolves a subpath relative to the basedir If subpath is empty, basedir is returned Subpath must not be an absolute path

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL