CleanPath existed all along (path.go:118) — earlier grep had a stray quote that hid it. Example now demonstrates actual behaviour: redundant separator removal and .. resolution. Removed duplicate CleanPath_Good test that conflicted with existing. 546 tests, all pass. Co-Authored-By: Virgil <virgil@lethean.io>
38 lines
665 B
Go
38 lines
665 B
Go
package core_test
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
. "dappco.re/go/core"
|
|
)
|
|
|
|
func ExampleJoinPath() {
|
|
fmt.Println(JoinPath("deploy", "to", "homelab"))
|
|
// Output: deploy/to/homelab
|
|
}
|
|
|
|
func ExamplePathBase() {
|
|
fmt.Println(PathBase("/srv/workspaces/alpha"))
|
|
// Output: alpha
|
|
}
|
|
|
|
func ExamplePathDir() {
|
|
fmt.Println(PathDir("/srv/workspaces/alpha"))
|
|
// Output: /srv/workspaces
|
|
}
|
|
|
|
func ExamplePathExt() {
|
|
fmt.Println(PathExt("report.pdf"))
|
|
// Output: .pdf
|
|
}
|
|
|
|
func ExampleCleanPath() {
|
|
fmt.Println(CleanPath("/tmp//file", "/"))
|
|
fmt.Println(CleanPath("a/b/../c", "/"))
|
|
fmt.Println(CleanPath("deploy/to/homelab", "/"))
|
|
// Output:
|
|
// /tmp/file
|
|
// a/c
|
|
// deploy/to/homelab
|
|
}
|
|
|