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

Dirname

Overview ​

Dirname returns the directory (path.dirname).

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

Signature ​

go
func Dirname(p string) string

Compare: Node.js · Standard Go · gox ​

js
path.dirname('/foo/bar.txt');
go
dir := filepath.Dir("/foo/bar.txt")
go
import "github.com/sahilkhaire/gox/path"

dir := path.Dirname("/foo/bar.txt")

Example ​

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

dir := path.Dirname("/foo/bar.txt")

Tips ​

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

Standard library alternative ​

Use the standard library directly:

go
dir := filepath.Dir("/foo/bar.txt")

← Back to path package overview

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