Code-Memo

path/filepath

Cross-platform filesystem paths (not URL paths — use net/url or path for those).

Join and clean
import "path/filepath"

p := filepath.Join("a", "b", "c.txt")
clean := filepath.Clean(`a/../b/./c`)
Base / dir / ext
base := filepath.Base(p)   // file name
dir := filepath.Dir(p)     // directory
ext := filepath.Ext(p)     // suffix including dot
Rel
rel, err := filepath.Rel("/a/b", "/a/b/c/d")
Walk
err := filepath.WalkDir(root, func(path string, d fs.DirEntry, err error) error {
	if err != nil {
		return err
	}
	if d.IsDir() && d.Name() == ".git" {
		return filepath.SkipDir
	}
	return nil
})

Prefer io/fs.WalkDir with os.DirFS when working with fs.FS abstractions.

Windows vs POSIX

filepath adapts separators; do not hand-build strings with / for Windows-only edge cases without tests.

os.PathSeparator / ListSeparator

When constructing PATH-style variables.