A go library to intuitively manipulate file names.
Functions:
FileBasegets the file name with extension of filepath but without the directoryFileDirectorygets the directory of filepath without the file nameFileExtensiongets the file extension of filepath without the leading dotFileNamegets the file name of filepath without the directory or extension
Examples of usage:
FilePath: /Users/user/directory/foo.txtFileDirectory: /Users/user/directoryFileBase: foo.txtFileName: fooFileExtension: 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