Skip to content

Latest commit

 

History

History
42 lines (28 loc) · 931 Bytes

README.md

File metadata and controls

42 lines (28 loc) · 931 Bytes

userglob

Build Status GoDoc

User homedir globbing for Go.

Installation

go get -u github.com/hazaelsan/userglob

Import

import "github.com/hazaelsan/userglob"

Usage

To perform globbing for an arbitrary user user:

import "github.com/hazaelsan/userglob"

if expanded, err := userglob.Glob("~user/some/path"); err == nil {
	fmt.Printf("Expanded path is %v", expanded)
}

The following two are similar, but using userglob is more resilient:

// $HOME may be manipulated or even missing
expanded := path.Join(os.Getenv("HOME"), "/some/path")

if expanded, err := userglob.Glob("~/some/path"); err == nil {
	fmt.Printf("Expanded path is %v", path)
}