Skip to content

Commit

Permalink
fix: Fix file ext
Browse files Browse the repository at this point in the history
  • Loading branch information
ginokent committed Aug 12, 2024
1 parent b38709e commit 2001b74
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions internal/arcgen/lang/go/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,20 @@ func generate(arcSrcSetSlice ARCSourceSetSlice) error {
}

if config.GenerateGoORMPackage() {
crudFileExt := ".crud" + genFileExt
ormFileExt := ".orm" + genFileExt

crudFiles := make([]string, 0)
ormFiles := make([]string, 0)
for _, arcSrcSet := range arcSrcSetSlice {
// closure for defer
if err := func() error {
filePathWithoutExt := strings.TrimSuffix(filepath.Base(arcSrcSet.Filename), fileExt)
filename := filepath.Join(config.GoORMOutputPath(), filePathWithoutExt+crudFileExt)
filename := filepath.Join(config.GoORMOutputPath(), filePathWithoutExt+ormFileExt)
f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, rw_r__r__)
if err != nil {
return errorz.Errorf("os.OpenFile: %w", err)
}
defer f.Close()
crudFiles = append(crudFiles, filename)
ormFiles = append(ormFiles, filename)

if err := fprintORM(
f,
Expand All @@ -84,14 +84,14 @@ func generate(arcSrcSetSlice ARCSourceSetSlice) error {
}

if err := func() error {
filename := filepath.Join(config.GoORMOutputPath(), "common"+crudFileExt)
filename := filepath.Join(config.GoORMOutputPath(), "common"+ormFileExt)
f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, rw_r__r__)
if err != nil {
return errorz.Errorf("os.OpenFile: %w", err)
}
defer f.Close()

if err := fprintORMCommon(f, bytes.NewBuffer(nil), arcSrcSetSlice, crudFiles); err != nil {
if err := fprintORMCommon(f, bytes.NewBuffer(nil), arcSrcSetSlice, ormFiles); err != nil {
return errorz.Errorf("sprint: %w", err)
}

Expand Down
10 changes: 5 additions & 5 deletions internal/arcgen/lang/go/generate_orm_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ const (
readManyFuncPrefix = "List"
)

func fprintORMCommon(osFile osFile, buf buffer, arcSrcSetSlice ARCSourceSetSlice, crudFiles []string) error {
content, err := generateORMCommonFileContent(buf, arcSrcSetSlice, crudFiles)
func fprintORMCommon(osFile osFile, buf buffer, arcSrcSetSlice ARCSourceSetSlice, ormFiles []string) error {
content, err := generateORMCommonFileContent(buf, arcSrcSetSlice, ormFiles)
if err != nil {
return errorz.Errorf("generateORMCommonFileContent: %w", err)
}
Expand All @@ -40,7 +40,7 @@ func fprintORMCommon(osFile osFile, buf buffer, arcSrcSetSlice ARCSourceSetSlice
}

//nolint:cyclop,funlen,gocognit,maintidx
func generateORMCommonFileContent(buf buffer, arcSrcSetSlice ARCSourceSetSlice, crudFiles []string) (string, error) {
func generateORMCommonFileContent(buf buffer, arcSrcSetSlice ARCSourceSetSlice, ormFiles []string) (string, error) {
astFile := &ast.File{
// package
Name: &ast.Ident{
Expand Down Expand Up @@ -95,8 +95,8 @@ func generateORMCommonFileContent(buf buffer, arcSrcSetSlice ARCSourceSetSlice,
// }
methods := make([]*ast.Field, 0)
fset := token.NewFileSet()
for _, crudFile := range crudFiles {
rootNode, err := parser.ParseFile(fset, crudFile, nil, parser.ParseComments)
for _, ormFile := range ormFiles {
rootNode, err := parser.ParseFile(fset, ormFile, nil, parser.ParseComments)
if err != nil {
// MEMO: parser.ParseFile err contains file path, so no need to log it
return "", errorz.Errorf("parser.ParseFile: %w", err)
Expand Down

0 comments on commit 2001b74

Please sign in to comment.