Documentation ¶
Overview ¶
Package dirs implements utility functions for creating, getting information on and removing directories.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetwdEvalSymLinks ¶
GetwdEvalSymLinks returns the working directory of the current process using os.GetWd(). Returns the path with all symbolic links resolved (equivalent to 'pwd -P'). Returns an error if os.Getwd or filepath.EvalSymlinks returns an error.
func GoRoot ¶
GoRoot returns the value for GOROOT for the current system. Similar to runtime.GOROOT(), but if the GOROOT environment variable is not set, falls back on the value provided by the output of running "go env GOROOT" rather than using sys.DefaultGoroot. This approach is more portable in situations where the binary is being run in an environment that is different from the one in which it is compiled.
func MustGetwdEvalSymLinks ¶
func MustGetwdEvalSymLinks() string
MustGetwdEvalSymLinks returns the result of GetwdEvalSymLinks. If GetwdEvalSymLinks returns an error, panics.
func RemoveAllFunc ¶
func RemoveAllFunc(path string) func()
RemoveAllFunc returns a function that calls os.RemoveAll on the specified path and prints any error that is encountered using fmt.Printf. Useful as a defer function to clean up directories created in tests.
func SetGoEnvVariables ¶
func SetGoEnvVariables() error
SetGoEnvVariables sets the values of the GOPATH and GOROOT environment variables to be the correct values with all symbolic links evaluated. The GOPATH to resolve is determined by using the original value of the GOPATH environment variable, while the GOROOT to resolve is determined using the GoRoot() function.
func SetwdWithRestorer ¶
SetwdWithRestorer sets the working directory to be the specified directory and returns a function that restores the working directory to the value before it was changed. The returned function is suitable for use in a defer call.
Types ¶
This section is empty.