gen icon indicating copy to clipboard operation
gen copied to clipboard

Unused imports added to models causes compilation to fail

Open jpmeijers opened this issue 3 years ago • 0 comments

Library version master@bac0f1d.

Outputs incorrect version number:

$ gen --version
v0.9.27 (08/04/2020)

Generates models with unused imports:

import (
	"database/sql" // unused
	"time"

	"github.com/satori/go.uuid" // unused

	"gorm.io/gorm"
)

Causes compilation to fail:

# <redacted>/model
<redacted>.go:4:2: imported and not used: "database/sql"
<redacted>.go:5:2: imported and not used: "time"
<redacted>.go:7:2: imported and not used: "github.com/satori/go.uuid" as uuid
<redacted>.go:4:2: imported and not used: "database/sql"
<redacted>.go:5:2: imported and not used: "time"
<redacted>.go:7:2: imported and not used: "github.com/satori/go.uuid" as uuid
<redacted>.go:4:2: imported and not used: "database/sql"
<redacted>.go:5:2: imported and not used: "time"
<redacted>.go:7:2: imported and not used: "github.com/satori/go.uuid" as uuid
<redacted>.go:4:2: imported and not used: "database/sql"
<redacted>.go:4:2: too many errors

Compilation finished with exit code 2

Goland complains, but allows me to optimise the imports for all the models, fixing the issue: Screenshot from 2022-06-04 12-18-35

jpmeijers avatar Jun 04 '22 10:06 jpmeijers