MCPcopy Create free account
hub / github.com/CPChain/chain / expandHome

Function expandHome

internal/debug/api.go:205–218  ·  view source on GitHub ↗

expands home directory in file paths. ~someuser/tmp will not be expanded.

(p string)

Source from the content-addressed store, hash-verified

203// expands home directory in file paths.
204// ~someuser/tmp will not be expanded.
205func expandHome(p string) string {
206 if strings.HasPrefix(p, "~/") || strings.HasPrefix(p, "~\\") {
207 home := os.Getenv("HOME")
208 if home == "" {
209 if usr, err := user.Current(); err == nil {
210 home = usr.HomeDir
211 }
212 }
213 if home != "" {
214 p = home + p[1:]
215 }
216 }
217 return filepath.Clean(p)
218}

Callers 3

StartCPUProfileMethod · 0.85
writeProfileFunction · 0.85
StartGoTraceMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected