filepath Package in Golang Last Updated : 22 Jun, 2020 Comments Improve Suggest changes Like Article Like Report Go language provides inbuilt support for implementing utility routines for manipulating filename paths in a way compatible with the target operating system-defined file paths with the help of the filepath package. This package uses either forward slashes or backslashes (depending on the operating system) to process paths e.g., URLs that always use forward slashes. Function Description Abs This function is used to return an absolute representation of path. Base This function is used to return the last element of path. Clean This function is used to return the shortest path name equivalent to the path by purely lexical processing. Dir This function is used to return all but the last element of path, typically the path's directory. EvalSymlinks This function is used to return the path name after the evaluation of any symbolic links. Ext This function is used to return the file name extension used by path. FromSlash This function is used to return the result of replacing each slash ('/') character in path with a separator character. Glob This function is used to return the names of all files matching pattern or nil if there is no matching file. HasPrefix It exists for historical compatibility and should not be used. IsAbs This function is used to check whether the path is absolute. Join This function is used to join any number of path elements into a single path, separating them with an OS specific Separator. Match This function is used to check whether name matches the shell file name pattern or not. Rel This function is used to return a relative path that is lexically equivalent to targpath when joined to basepath with an intervening separator. Split This function is used to split path immediately following the final Separator, separating it into a directory and file name component. SplitList This function is used to splits a list of paths joined by the OS-specific ListSeparator, usually found in PATH or GOPATH environment variables. ToSlash This function is used to return the result of replacing each separator character in path with a slash ('/') character. VolumeName This function is used to returns leading volume name. Walk This function is used to walk the file tree rooted at root, calling walkFn for each file or directory in the tree, including root. Example 1 : Go // Golang program to illustrate the usage of // filepath.Join() function // Including the main package package main // Importing fmt and path/filepath import ( "fmt" "path/filepath" ) // Calling main func main() { // Calling the Join() function fmt.Println(filepath.Join("G", "F", "G")) fmt.Println(filepath.Join("G/F", "G")) fmt.Println(filepath.Join("gfg", "GFG")) fmt.Println(filepath.Join("Geeks", "for", "Geeks")) } Output: G/F/G G/F/G gfg/GFG Geeks/for/Geeks Example 2: Go // Golang program to illustrate the usage of // filepath.Abs() function // Including the main package package main // Importing fmt and path/filepath import ( "fmt" "path/filepath" ) // Calling main func main() { // Calling the Abs() function to get // absolute representation of the specified path fmt.Println(filepath.Abs("/home/gfg")) fmt.Println(filepath.Abs(".gfg")) fmt.Println(filepath.Abs("/gfg")) fmt.Println(filepath.Abs(":gfg")) } Output: /home/gfg /.gfg /gfg /:gfg Comment More infoAdvertise with us Next Article filepath Package in Golang ankita_saini Follow Improve Article Tags : Go Language Golang-filepath Similar Reads fmt Package in GoLang Prerequisite: Packages in GoLang and Import in GoLang Technically defining, a package is essentially a container of source code for some specific purpose. Packages are very essential as in all programs ranging from the most basic programs to high-level complex codes, these are used. A package ensur 13 min read Packages in Golang Packages are the most powerful part of the Go language. The purpose of a package is to design and maintain a large number of programs by grouping related features together into single units so that they can be easy to maintain and understand and independent of the other package programs. This modula 5 min read base64 Package in Golang Go language provides inbuilt support for base64 encoding/decoding and has functions that could be used to perform operations on the given data using the base64 package. .base64-golang-table { border-collapse: collapse; width: 100%; } .base64-golang-table td { border: 1px solid #5fb962; text-align: l 3 min read string package in Golang Go language provides a string package that holds different types of functions to manipulate UTF-8 encoded strings. To access the function of the string package you need to import a string package in your program with the help of the import keyword.  FunctionDescriptionfunc CompareThis function is u 8 min read strconv package in Golang Go language provides a strconv package that implements conversions to and from string representations of basic data types. To access the functions of the strconv package you need to import the strconv package in your program with the help of the import keyword. .strconv-golang-table { border-collaps 5 min read How to Create Your Own Package in Golang? Go language is a high-level programming language developed at Google Inc. A high-level language is in simple words, the programming language category created by humans for human understanding. Before we jump onto high terminologies as packages, modules, functions, etc. let's write the most basic pro 7 min read Time Formatting in Golang Golang supports time formatting and parsing via pattern-based layouts. To format time, we use the Format() method which formats a time.Time object. Syntax: func (t Time) Format(layout string) string We can either provide custom format or predefined date and timestamp format constants are also availa 2 min read Type Assertions in Golang Type assertions in Golang provide access to the exact type of variable of an interface. If already the data type is present in the interface, then it will retrieve the actual data type value held by the interface. A type assertion takes an interface value and extracts from it a value of the specifie 2 min read Templates in GoLang Template in Golang is a robust feature to create dynamic content or show customized output to the user. Golang has two packages with templates: text/template html/template There are mainly 3 parts of a template which are as follows: 1. Actions They are data evaluations, control structures like loops 4 min read Parsing Time in Golang Parsing time is to convert our time to Golang time object so that we can extract information such as date, month, etc from it easily. We can parse any time by using time.Parse function which takes our time string and format in which our string is written as input and if there is no error in our form 2 min read Like