Skip to content

Unused imports added to models causes compilation to fail #185

@jpmeijers

Description

@jpmeijers

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions