MCPcopy Create free account
hub / github.com/driangle/taskmd / expandTilde

Function expandTilde

apps/cli/internal/cli/registry.go:162–174  ·  view source on GitHub ↗

expandTilde replaces a leading ~ with the user's home directory.

(path string)

Source from the content-addressed store, hash-verified

160
161// expandTilde replaces a leading ~ with the user's home directory.
162func expandTilde(path string) (string, error) {
163 if path == "~" {
164 return os.UserHomeDir()
165 }
166 if strings.HasPrefix(path, "~/") {
167 home, err := os.UserHomeDir()
168 if err != nil {
169 return "", fmt.Errorf("expand ~: %w", err)
170 }
171 return filepath.Join(home, path[2:]), nil
172 }
173 return path, nil
174}

Callers 3

TestExpandTildeFunction · 0.85
globalConfigPathFunction · 0.85
resolvePathFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestExpandTildeFunction · 0.68