diff --git a/examples/file-paths/file-paths.go b/examples/file-paths/file-paths.go index 75b017d..c001dfd 100644 --- a/examples/file-paths/file-paths.go +++ b/examples/file-paths/file-paths.go @@ -32,22 +32,24 @@ func main() { fmt.Println("Dir(p):", filepath.Dir(p)) fmt.Println("Base(p):", filepath.Base(p)) - // To check whether a path is absolute, use `IsAbs`. + // We can check whether a path is absolute. fmt.Println(filepath.IsAbs("dir/file")) fmt.Println(filepath.IsAbs("/dir/file")) filename := "config.json" - // To find a file's extension, use `Ext`. + // Some file names have extensions following a dot. We + // can split the extension out of such names with `Ext`. ext := filepath.Ext(filename) fmt.Println(ext) // To find the file's name with the extension removed, - // use `TrimSuffix`. + // use `strings.TrimSuffix`. fmt.Println(strings.TrimSuffix(filename, ext)) // `Rel` finds a relative path between a *base* and a - // *target*. + // *target*. It returns an error if the target cannot + // be made relative to base. rel, err := filepath.Rel("a/b", "a/b/t/file") if err != nil { panic(err) diff --git a/examples/file-paths/file-paths.hash b/examples/file-paths/file-paths.hash index 7cc06ab..f1610a1 100644 --- a/examples/file-paths/file-paths.hash +++ b/examples/file-paths/file-paths.hash @@ -1,2 +1,2 @@ -4611ff69626490eb50673a739707d870fac79142 -eUhAltl7_sI +1215302b9e59ee9dee21dcd3c47d5f6c672fb058 +QIitbMNiFRx diff --git a/public/file-paths b/public/file-paths index 9085662..65e3886 100644 --- a/public/file-paths +++ b/public/file-paths @@ -20,7 +20,7 @@ between operating systems; dir/file on Linux vs. - +
package main
@@ -109,7 +109,7 @@ return both in the same call.

-

To check whether a path is absolute, use IsAbs.

+

We can check whether a path is absolute.

@@ -135,7 +135,8 @@ return both in the same call.

-

To find a file’s extension, use Ext.

+

Some file names have extensions following a dot. We +can split the extension out of such names with Ext.

@@ -150,7 +151,7 @@ return both in the same call.

To find the file’s name with the extension removed, -use TrimSuffix.

+use strings.TrimSuffix.

@@ -164,7 +165,8 @@ use TrimSuffix.

Rel finds a relative path between a base and a -target.

+target. It returns an error if the target cannot +be made relative to base.