18
pathx/path.go
Normal file
18
pathx/path.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package pathx
|
||||
|
||||
import (
|
||||
"path"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func FilenameWithoutExt(s string) string {
|
||||
if s == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
filename := path.Base(s)
|
||||
if ext := path.Ext(s); ext != "" {
|
||||
filename = strings.TrimSuffix(filename, ext)
|
||||
}
|
||||
return filename
|
||||
}
|
||||
Reference in New Issue
Block a user