Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
import "os"
import "fmt"
import "path/filepath"filepath.Dir("/home/myname/")/home/mynamefilepath.Dir("/home/myname")/homefilepath.Base("/usr/local/bin")binfilepath.Base("/usr/local/bin/abc.txt")abc.txtfilepath.Base("https://www.legendu.net")www.legendu.netfilepath.Join("/usr/", "local/bin")/usr/local/binfilepath.Glob¶
Note: The glob package in Python and Rust behave similarly.
Both of them find all files and subdirectories for the pattern **/*.
However,
filepath.Glob
behaves different from those 2 packages.
filepath.Glob
treats **/* as */*.
entries, err := filepath.Glob("./**/*")
entries[.ipynb_checkpoints/abc-checkpoint.txt .ipynb_checkpoints/hands-on-the-filepath-library-in-golang-checkpoint.ipynb test/.ipynb_checkpoints test/test.txt test/test2]for _, entry := range entries {
fmt.Printf("%s\n", entry)
}.ipynb_checkpoints/abc-checkpoint.txt
.ipynb_checkpoints/hands-on-the-filepath-library-in-golang-checkpoint.ipynb
test/.ipynb_checkpoints
test/test.txt
test/test2