Skip to content
master
Switch branches/tags
Go to file
Code
This branch is 10 commits ahead, 5 commits behind mitchellh:master.

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

homedir

Linux/OSX Build Status Windows Build Status Codecov Go Report Card Go docs

A Go library for getting the user's home directory without cgo allowing for cross compilation.

This is a tracking fork of mitchellh/go-homedir that is kept up-to-date with changes upstream. The original uses runtime checks to select the logic used. This fork uses go build tags rather than runtime checks. This was suggested in a two PRs (#13, #10) but wasn't a fit for the specific purpose that the original had been developed for, leading to this fork.

Usage

import "4d63.com/homedir"

// Call `homedir.Dir()` to get the home directory of the current user.
homePath := homedir.Dir()

// Call `homedir.Expand()` to expand the `~` in a path to the home directory of the current user.
absPath := homedir.Expand("~/a/path/in/the/home")

Why not use the built in os/user?

The built-in os/user package requires cgo on Darwin (Mac) systems. This means that any Go code that uses that package cannot cross compile. Much of the time the use for os/user is only to retrieve the home directory, which we can do for the current user without cgo. This library does that, enabling cross-compilation.

About

A go package for detecting and expanding the user's home directory without cgo.

Resources

License

Releases

No releases published

Packages

No packages published

Languages