Generate groups and reorders imports incorrectly
gqlgen version: v0.17.66 go version: 1.23.3
full repro: https://github.com/mdakovac/gqlgen-import-sorting/tree/main
Go lets you group imports by separating them with a newline, however when you run the generate command, this grouping is broken.
import statement before generate in graph/schema.resolvers.go file
import (
"context"
"fmt"
"github.com/rs/zerolog"
"github.com/example/gqlgen-import-sorting/graph/model"
"github.com/spf13/viper"
)
after generate
import (
"context"
"fmt"
"github.com/example/gqlgen-import-sorting/graph/model"
"github.com/rs/zerolog"
"github.com/spf13/viper"
)
Which file is getting altered in this way?
graph/schema.resolvers.go is the file, added to description
Thanks! That is irksome, and I'm not sure why that is happening. If you care to make a PR to fix it, I would appreciate it. I would have thought this would have been the result:
import (
"context"
"fmt"
"github.com/rs/zerolog"
"github.com/spf13/viper"
"github.com/example/gqlgen-import-sorting/graph/model"
)