A go
library to intuitively manipulate file names.
Functions:
FileBase
gets the file name with extension of filepath but without the directoryFileDirectory
gets the directory of filepath without the file nameFileExtension
gets the file extension of filepath without the leading dotFileName
gets the file name of filepath without the directory or extension
Examples of usage:
FilePath: /Users/user/directory/foo.txt
FileDirectory: /Users/user/directory
FileBase: foo.txt
FileName: foo
FileExtension: txt
// Sample program
package main
import (
"fmt"
"github.com/marekkowalczyk/filenames"
)
func main() {
filepath := "/Users/user/directory/foo.txt"
fmt.Println("FilePath:\t", filepath)
fmt.Println("FileDirectory:\t", filenames.FileDirectory(filepath))
fmt.Println("FileBase:\t", filenames.FileBase(filepath))
fmt.Println("FileName:\t", filenames.FileName(filepath))
fmt.Println("FileExtension:\t", filenames.FileExtension(filepath))
}
filenames by Marek Kowalczyk is licensed under CC BY-SA 4.0