path/filepath manipulates paths for the host operating system. On this machine the separator is /. Join cleans separators. Base, Dir, and Ext split a path. IsAbs reports whether it starts at the root.
path/filepath
/
Join
Base
Dir
Ext
IsAbs
(println (path:filepath.Join "dir" "sub" "file.txt")) (println (path:filepath.Base "/tmp/a/file.txt")) (println (path:filepath.Dir "/tmp/a/file.txt")) (println (path:filepath.Ext "/tmp/a/file.txt")) (println (path:filepath.IsAbs "/tmp/a")) (println (path:filepath.IsAbs "a/b"))
Ext includes the dot.
$ glj file-paths.glj dir/sub/file.txt file.txt /tmp/a .txt true false
Next example: Directories.
A hands-on tour in the style of Go by Example. Glojure is a Clojure interpreter hosted on Go.