smallnest / gen

Converts a database into gorm structs and RESTful api
Apache License 2.0
1.43k stars 233 forks source link

Unused imports added to models causes compilation to fail #185

Open jpmeijers opened 2 years ago

jpmeijers commented 2 years ago

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