Skip to content
Node: path.extname(p)github.com/sahilkhaire/gox/path

Extname

Overview

Extname returns the extension including dot (path.extname).

If you are coming from Node.js, the closest pattern is path.extname(p).

Signature

go
func Extname(p string) string

Compare: Node.js · Standard Go · gox

js
path.extname('file.txt');
go
ext := filepath.Ext("file.txt")
go
import "github.com/sahilkhaire/gox/path"

ext := path.Extname("file.txt")

Example

go
import "github.com/sahilkhaire/gox/path"

ext := path.Extname("file.txt")

Tips

Import github.com/sahilkhaire/gox/path and call Extname directly. See the comparison below for the standard library equivalent.

Standard library alternative

Use the standard library directly:

go
ext := filepath.Ext("file.txt")

Back to path package overview

MIT Licensed · Built for Node.js developers moving to Go