Skip to content

Commit 2cb64de

Browse files
committed
fix: 修正了在使用命令行参数指定output时,生成模板文件中的包路径与预期不一致的错误
1 parent 20c7a8c commit 2cb64de

File tree

6 files changed

+12
-9
lines changed

6 files changed

+12
-9
lines changed

server/cmd/gen/gen.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ type GenDomain struct {
6161
DomainName string
6262
UnderlineName string
6363
TableName string
64+
OutputDir string
6465
}
6566

6667
func main() {
@@ -72,11 +73,13 @@ func main() {
7273
DomainName: *domain,
7374
UnderlineName: stringx.CamelToSnake(*domain),
7475
TableName: *tableName,
76+
OutputDir: *outputDir,
7577
}
7678

7779
if outputDir == nil || *outputDir == "" {
7880
outputDir = new(string)
7981
*outputDir = "internal/" + gen.UnderlineName
82+
gen.OutputDir = *outputDir
8083
}
8184

8285
if tableName == nil || *tableName == "" {

server/cmd/gen/templates/module.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
package {{.UnderlineName}}
1616

1717
import (
18-
"github.com/chenmingyong0423/fnote/server/internal/{{.UnderlineName}}/internal/service"
19-
"github.com/chenmingyong0423/fnote/server/internal/{{.UnderlineName}}/internal/web"
18+
"github.com/chenmingyong0423/fnote/server/{{.OutputDir}}/internal/service"
19+
"github.com/chenmingyong0423/fnote/server/{{.OutputDir}}/internal/web"
2020
)
2121

2222
type (

server/cmd/gen/templates/repository.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
package repository
1616

1717
import (
18-
"github.com/chenmingyong0423/fnote/server/internal/{{.UnderlineName}}/internal/repository/dao"
18+
"github.com/chenmingyong0423/fnote/server/{{.OutputDir}}/internal/repository/dao"
1919
)
2020

2121
type I{{.DomainName}}Repository interface {

server/cmd/gen/templates/service.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
package service
1616

1717
import (
18-
"github.com/chenmingyong0423/fnote/server/internal/{{.UnderlineName}}/internal/repository"
18+
"github.com/chenmingyong0423/fnote/server/{{.OutputDir}}/internal/repository"
1919
)
2020

2121

server/cmd/gen/templates/web.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
package web
1616

1717
import (
18-
"github.com/chenmingyong0423/fnote/server/internal/{{.UnderlineName}}/internal/service"
18+
"github.com/chenmingyong0423/fnote/server/{{.OutputDir}}/internal/service"
1919
"github.com/gin-gonic/gin"
2020
)
2121

server/cmd/gen/templates/wire.tmpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
package {{.UnderlineName}}
1818

1919
import (
20-
"github.com/chenmingyong0423/fnote/server/internal/{{.UnderlineName}}/internal/repository"
21-
"github.com/chenmingyong0423/fnote/server/internal/{{.UnderlineName}}/internal/repository/dao"
22-
"github.com/chenmingyong0423/fnote/server/internal/{{.UnderlineName}}/internal/service"
23-
"github.com/chenmingyong0423/fnote/server/internal/{{.UnderlineName}}/internal/web"
20+
"github.com/chenmingyong0423/fnote/server/{{.OutputDir}}/internal/repository"
21+
"github.com/chenmingyong0423/fnote/server/{{.OutputDir}}/internal/repository/dao"
22+
"github.com/chenmingyong0423/fnote/server/{{.OutputDir}}/internal/service"
23+
"github.com/chenmingyong0423/fnote/server/{{.OutputDir}}/internal/web"
2424
"github.com/google/wire"
2525
"go.mongodb.org/mongo-driver/mongo"
2626
)

0 commit comments

Comments
 (0)