Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!
In [6]:
import "os"
import "fmt"
import "path/filepath"
In [2]:
filepath.Dir("/home/myname/")
Out[2]:
In [3]:
filepath.Dir("/home/myname")
Out[3]:
In [2]:
filepath.Base("/usr/local/bin")
Out[2]:
In [3]:
filepath.Base("/usr/local/bin/abc.txt")
Out[3]:
In [21]:
filepath.Base("https://www.legendu.net")
Out[21]:
In [2]:
filepath.Join("/usr/", "local/bin")
Out[2]:
filepath.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 */*
.
In [19]:
entries, err := filepath.Glob("./**/*")
entries
Out[19]:
In [20]:
for _, entry := range entries {
fmt.Printf("%s\n", entry)
}
In [ ]: