The filepath package contains less than 20 functions, which is a small number compared to the packages of the standard library, and it's used to manipulate paths. Let's take a quick look at these functions:
- func Abs(path string) (string, error): Returns the absolute version of the path that's passed by joining it to the current working directory (if it's not already absolute), and then cleans it.
- func Base(path string) string: Gives the last element of the path (base). For instance, path/to/some/file returns the file. Note that if the path is empty, this function returns a . (dot) path.
- func Clean(path string) string: Returns the shortest version of the path by applying a series of defined rules. It does operations like ...