← All notes

Go path: slash-separated logical paths, not OS file paths

Answer: The path package is for slash-separated paths such as the paths in URLs, not Windows file paths.

When to use it

It implements utility routines for those slash separated paths.

Use it only for paths separated by forward slashes.

To manipulate operating system paths, use the path filepath package.

This package does not deal with Windows paths that have drive letters or backslashes.

Cleaning rules

Clean eliminates each . path name element, which is the current directory.

The returned path ends in a slash only if it is the root.

It also drops each inner .. element along with the non-.. element that precedes it.

If that process yields an empty string, Clean returns a single dot.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: The Go Authors, path package reference; The Go Authors, path source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: The Go Authors, path package reference; The Go Authors, path source. BSD-3-Clause (https://go.dev/LICENSE). Copyright The Go Authors.

Cite this

Permanent ID: iil:note:8yxa5yff

iinventedlight. 2026. "Go path: slash-separated logical paths, not OS file paths." iinventedlight Library, iil:note:8yxa5yff, version of 2026-11-24. https://iinventedlight.com/library/notes/go-path/. License: CC-BY-4.0.

@misc{iil_note_8yxa5yff,
  author = {{iinventedlight}},
  title = {{Go path: slash-separated logical paths, not OS file paths}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-24},
  url = {https://iinventedlight.com/library/notes/go-path/},
  note = {Permanent ID iil:note:8yxa5yff. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/go-path.md.