Skip to content

Commit

Permalink
improve comment replacement regex pattern for command gen service (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
gqcn committed Aug 8, 2023
1 parent 932f8c4 commit 243fe73
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/gf/internal/cmd/genservice/genservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (c CGenService) Service(ctx context.Context, in CGenServiceInput) (out *CGe
return nil, err
}
// remove all comments.
fileContent, err = gregex.ReplaceString(`//(.*)|(?s)/\*(.*?)\*/`, "", fileContent)
fileContent, err = gregex.ReplaceString(`(//.*)|((?s)/\*.*?\*/)`, "", fileContent)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/gf/internal/cmd/genservice/genservice_generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (c CGenService) isToGenerateServiceGoFile(dstPackageName, filePath string,
return true
}
// remove all comments.
fileContent, err = gregex.ReplaceString(`/[/|\*](.*)`, "", fileContent)
fileContent, err = gregex.ReplaceString(`(//.*)|((?s)/\*.*?\*/)`, "", fileContent)
if err != nil {
panic(err)
return false
Expand Down

0 comments on commit 243fe73

Please sign in to comment.