Creating an entity called "sync" will cause a compilation error of the generated code
- Dominant language
- Go
- Stars
- 17.2k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
- [x] The issue is present in the latest release.
- [x] I have searched the [issues](https://github.com/ent/ent/issues) of this repository and believe that this is not a duplicate.
## Current Behavior 😯
When creating a sync entity like this:
```
package schema
import (
"entgo.io/ent"
"entgo.io/ent/schema/edge"
"entgo.io/ent/schema/field"
)
// Sync schema
type Sync struct {
ent.Schema
}
// Fields of the Sync.
func (s Sync) Fields() []ent.Field {
return []ent.Field{
}
}
// Edges of the Sync.
func (Sync) Edges() []ent.Edge {
return []ent.Edge{
}
}
```
The generated code will not compile, instead gives the following error:
```
# github.com/advanderveer/extron/model
model/mutation.go:16:2: sync redeclared as imported package name
previous declaration at model/mutation.go:8:2
...
```
Most probably because it collides with the stdlib "sync" package.
## Expected Behavior 🤔
Expected it to compile, or be warned that some entity names are reserved.
## Steps to Reproduce 🕹
Steps:
1. Setup an entity
2. Generate ent code
3. Compile the binary
## Your Environment 🌎
go.mod:
```
module github.com/advanderveer/extron
go 1.16
require (
entgo.io/contrib v0.0.0-20210503071007-94b55dee6550
entgo.io/ent v0.8.0
github.com/jackc/pgx/v4 v4.12.0 // indirect
github.com/mattn/go-sqlite3 v1.14.6
)
```
Contributor guide
Assessment
This issue has not been assessed yet.