Skip to content

Commit

Permalink
use filepath.Abs instead
Browse files Browse the repository at this point in the history
  • Loading branch information
yinloo-ola committed Aug 28, 2024
1 parent a501f17 commit da95f72
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions golalib/golalib.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/olachat/gola/v2/structs"
)

// GenWithParser generate orm stubs from config provided
func GenWithParser(config mysqlparser.MySQLParserConfig, output string) int {
m := &mysqlparser.MySQLParser{}
db, err := m.Assemble(config)
Expand All @@ -32,18 +33,11 @@ func GenWithParser(config mysqlparser.MySQLParserConfig, output string) int {
output = "temp"
}

if !strings.HasPrefix(output, "/") {
// output folder is relative path
wd, err := os.Getwd()
if err != nil {
wd = "."
}
output = wd + string(filepath.Separator) + output
}

if !strings.HasSuffix(output, string(filepath.Separator)) {
output = output + string(filepath.Separator)
output, err = filepath.Abs(output)
if err != nil {
panic(err)
}
output += string(filepath.Separator)

var hasFailure atomic.Bool
wg := &sync.WaitGroup{}
Expand Down

0 comments on commit da95f72

Please sign in to comment.