(Feat): Initial Commit
Some checks failed
Build & Test / build-test (push) Has been cancelled
Build & Test / swagger-codegen-cli (push) Has been cancelled
CodeQL / Analyze (go) (push) Has been cancelled

This commit is contained in:
2026-07-03 19:41:31 +05:30
commit 7e940c83a7
461 changed files with 45002 additions and 0 deletions

40
internal/util/path.go Normal file
View File

@@ -0,0 +1,40 @@
// nolint:revive
package util
import (
"path/filepath"
"strings"
)
// FileNameWithoutExtension returns the name of the file referenced by the
// provided path without the file's extension.
// The function accepts a full (local) file path as well, only the latest
// element of the path will be considered as a name.
// If the provided path is empty or consists entirely of separators, an
// empty string will be returned.
func FileNameWithoutExtension(path string) string {
base := filepath.Base(path)
if base == "." || base == "/" {
return ""
}
return strings.TrimSuffix(base, filepath.Ext(path))
}
// FileNameAndExtension returns the name of the file referenced by the
// provided path as well as its extension as separated strings.
// The function accepts a full (local) file path as well, only the latest
// element of the path will be considered as a name.
// If the provided path is empty or consists entirely of separators,
// empty strings will be returned.
func FileNameAndExtension(path string) (string, string) {
base := filepath.Base(path)
if base == "." || base == "/" {
return "", ""
}
extension := filepath.Ext(path)
fileName := strings.TrimSuffix(base, extension)
return fileName, extension
}