[Golang] Get Filename Without Extension


Use Go standard library to get file name without extension.

import (
      "path"
      "strings"
)

func FilenameWithoutExtension(fn string) string {
      return strings.TrimSuffix(fn, path.Ext(fn))
}

Run Code on Go Playground


Tested on: