Skip to content

hazaelsan/userglob

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

User homedir globbing for Go.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages