Skip to content

Commit

Permalink
feat:wire文件生成逻辑判断
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoxiaosu committed Jun 30, 2023
1 parent 69d12b1 commit 97a16c8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 24 deletions.
15 changes: 7 additions & 8 deletions protoc-gen-go-crud/deliveries/wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"log"
"os"
"path/filepath"
"strings"
"text/template"
)
Expand Down Expand Up @@ -53,13 +52,13 @@ var ProviderSet = wire.NewSet({{ range $index, $element := .FunctionNames }}{{ i
}

// 文件检查
dir := filepath.Dir(filename)
if _, err := os.Stat(dir); os.IsNotExist(err) {
err := os.MkdirAll(dir, 0755)
if err != nil {
log.Fatalf("failed to create directory: %v", err)
}
}
//dir := filepath.Dir(filename)
//if _, err := os.Stat(dir); os.IsNotExist(err) {
// err := os.MkdirAll(dir, 0755)
// if err != nil {
// log.Fatalf("failed to create directory: %v", err)
// }
//}

// 检查文件是否存在,如果不存在则创建它
if _, err := os.Stat(filename); os.IsNotExist(err) {
Expand Down
Binary file modified protoc-gen-go-crud/protoc-gen-go-crud
Binary file not shown.
15 changes: 7 additions & 8 deletions protoc-gen-go-crud/repositories/wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"log"
"os"
"path/filepath"
"strings"
"text/template"
)
Expand Down Expand Up @@ -52,13 +51,13 @@ var ProviderSet = wire.NewSet({{ range $index, $element := .FunctionNames }}{{ i
}

// 目录检查
dir := filepath.Dir(filename)
if _, err := os.Stat(dir); os.IsNotExist(err) {
err := os.MkdirAll(dir, 0755)
if err != nil {
log.Fatalf("failed to create directory: %v", err)
}
}
//dir := filepath.Dir(filename)
//if _, err := os.Stat(dir); os.IsNotExist(err) {
// err := os.MkdirAll(dir, 0755)
// if err != nil {
// log.Fatalf("failed to create directory: %v", err)
// }
//}

// 检查文件是否存在,如果不存在则创建它
if _, err := os.Stat(filename); os.IsNotExist(err) {
Expand Down
15 changes: 7 additions & 8 deletions protoc-gen-go-crud/usecase/wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"log"
"os"
"path/filepath"
"strings"
"text/template"
)
Expand Down Expand Up @@ -53,13 +52,13 @@ var ProviderSet = wire.NewSet({{ range $index, $element := .FunctionNames }}{{ i
}

// 目录检查
dir := filepath.Dir(filename)
if _, err := os.Stat(dir); os.IsNotExist(err) {
err := os.MkdirAll(dir, 0755)
if err != nil {
log.Fatalf("failed to create directory: %v", err)
}
}
//dir := filepath.Dir(filename)
//if _, err := os.Stat(dir); os.IsNotExist(err) {
// err := os.MkdirAll(dir, 0755)
// if err != nil {
// log.Fatalf("failed to create directory: %v", err)
// }
//}

// 检查文件是否存在,如果不存在则创建它
if _, err := os.Stat(filename); os.IsNotExist(err) {
Expand Down

0 comments on commit 97a16c8

Please sign in to comment.