Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

path: include a function to split or remove the extension #5366

Closed
gopherbot opened this issue Apr 29, 2013 · 2 comments
Closed

path: include a function to split or remove the extension #5366

gopherbot opened this issue Apr 29, 2013 · 2 comments

Comments

@gopherbot
Copy link

by superjoe30:

Example:

http://play.golang.org/p/cJNuTP6nJN

My example implementation of the function:

func removeExtension(filename string) string {
    return filename[0:len(filename)-len(path.Ext(filename))]
}

In Python this works like this:

>>> import os
>>> os.path.splitext("/a/b/foo.ogg")
('/a/b/foo', '.ogg')
>>> os.path.splitext("/a/b/foo.")
('/a/b/foo', '.')
>>> os.path.splitext("/a/b/foo")
('/a/b/foo', '')

Can we have something like this in the path pkg?
@ianlancetaylor
Copy link
Contributor

Comment 1:

Note: if we add this to path we should add it to path/filepath as well.

Labels changed: added priority-later, packagechange, removed priority-triage.

@robpike
Copy link
Contributor

robpike commented May 2, 2013

Comment 2:

return strings.TrimSuffix(path.Ext(filename))
That's easy enough that adding more functions to path and filepath does not seem
warranted.

Status changed to WorkingAsIntended.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants