Fixed cross-platform path compatibility

This commit is contained in:
Jamius Siam 2024-11-24 21:41:52 +06:00
parent b08dd48c71
commit d6f1f28db8

View file

@ -8,6 +8,7 @@ import (
"github.com/go-jet/jet/v2/internal/utils/errfmt" "github.com/go-jet/jet/v2/internal/utils/errfmt"
"github.com/go-jet/jet/v2/internal/utils/strslice" "github.com/go-jet/jet/v2/internal/utils/strslice"
"os" "os"
"path/filepath"
"strings" "strings"
"github.com/go-jet/jet/v2/generator/metadata" "github.com/go-jet/jet/v2/generator/metadata"
@ -79,12 +80,19 @@ func init() {
flag.StringVar(&tablePkg, "table-pkg", "table", "Relative path for the Table files package from the destination directory.") flag.StringVar(&tablePkg, "table-pkg", "table", "Relative path for the Table files package from the destination directory.")
flag.StringVar(&viewPkg, "view-pkg", "view", "Relative path for the View files package from the destination directory.") flag.StringVar(&viewPkg, "view-pkg", "view", "Relative path for the View files package from the destination directory.")
flag.StringVar(&enumPkg, "enum-pkg", "enum", "Relative path for the Enum files package from the destination directory.") flag.StringVar(&enumPkg, "enum-pkg", "enum", "Relative path for the Enum files package from the destination directory.")
}
func main() {
flag.Usage = usage flag.Usage = usage
flag.Parse() flag.Parse()
// Convert the OS-specific path separator to slashes for cross-platform compatibility.
destDir = filepath.ToSlash(destDir)
modelPkg = filepath.ToSlash(modelPkg)
tablePkg = filepath.ToSlash(tablePkg)
viewPkg = filepath.ToSlash(viewPkg)
enumPkg = filepath.ToSlash(enumPkg)
}
func main() {
if dsn == "" && (source == "" || host == "" || port == 0 || user == "" || dbName == "") { if dsn == "" && (source == "" || host == "" || port == 0 || user == "" || dbName == "") {
printErrorAndExit("ERROR: required flag(s) missing") printErrorAndExit("ERROR: required flag(s) missing")
} }