Skip to content

Commit

Permalink
fix: isMakeComment
Browse files Browse the repository at this point in the history
  • Loading branch information
Bin-Huang committed Aug 16, 2022
1 parent 5aaf262 commit 3dff4df
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ See [more examples here](https://github.com/Bin-Huang/newc/tree/master/test)
Without manual installation, just add this comment line to the struct. Go will automatically install this tool if missing.

```go
//go:generate go run github.com/Bin-Huang/[email protected].0
//go:generate go run github.com/Bin-Huang/[email protected].1
```

For example:

```go
//go:generate go run github.com/Bin-Huang/[email protected].0
//go:generate go run github.com/Bin-Huang/[email protected].1
type UserService struct {
baseService
userRepository *repositories.UserRepository
Expand Down Expand Up @@ -123,7 +123,7 @@ Don't worry about the imports, variable naming, and code style in the generated
It doesn't break the work of other people who don't have installed this tool in collaboration. Go will automatically install this tool if missing.

```go
//go:generate go run github.com/Bin-Huang/[email protected].0
//go:generate go run github.com/Bin-Huang/[email protected].1
```

## Sponsoring
Expand Down
6 changes: 3 additions & 3 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ func NewUserService(baseService baseService, userRepository *repositories.UserRe
无需手动安装,只需要给结构体添加下面这行注释就行。Go 会在缺失时自动下载这个工具。

```go
//go:generate go run github.com/Bin-Huang/[email protected].0
//go:generate go run github.com/Bin-Huang/[email protected].1
```

比如这样:

```go
//go:generate go run github.com/Bin-Huang/[email protected].0
//go:generate go run github.com/Bin-Huang/[email protected].1
type UserService struct {
baseService
userRepository *repositories.UserRepository
Expand Down Expand Up @@ -123,7 +123,7 @@ func NewController(logger *zap.Logger, debug bool) *Controller {
就算其他同事没有安装这个工具,这么做也不会影响到他们的工作。因为 Go 会在必要时自动安装这个工具。

```go
//go:generate go run github.com/Bin-Huang/[email protected].0
//go:generate go run github.com/Bin-Huang/[email protected].1
```

## 赞赏
Expand Down
2 changes: 1 addition & 1 deletion parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func isMakeComment(s string) bool {
}
s = strings.TrimLeft(s, "//go:generate")
s = strings.TrimSpace(s)
return strings.HasPrefix(s, "newc ")
return strings.HasPrefix(s, "newc ") || strings.Contains(s, "github.com/Bin-Huang/newc")
}

// isInitModeEnable check if this struct enable the init mode
Expand Down

0 comments on commit 3dff4df

Please sign in to comment.