Go by Example: File Name Parsing

File name parsing could did by path package. Ref: golang.org

package main
import (
	"fmt"
	"path"
)
func main() {
	fmt.Println(path.Dir("/a/b/c/d.e"))

Note: Ext() get the extra dot (eg. .e instead of e)

	fmt.Println(path.Ext("/a/b/c/d.e"))
	fmt.Println(path.Base("/a/b/c/d.e"))
	fmt.Println(path.Split("/a/b/../c/d.e"))
	fmt.Println(path.Clean("/a/b/../c/d.e"))
}
$ go run file-name-parsing.go
/a/b/c
.e
d.e
/a/b/../c/ d.e
/a/c/d.e

Previous example: Writing Files.

Next example: Line Filters.