Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imports not generated correctly #40

Open
pierznj opened this issue Jun 26, 2017 · 3 comments
Open

Imports not generated correctly #40

pierznj opened this issue Jun 26, 2017 · 3 comments
Labels
Milestone

Comments

@pierznj
Copy link

pierznj commented Jun 26, 2017

In my template I have these imports:

import (
"errors"
"fmt"
"strings"

"github.com/deoxxa/gojson"
"github.com/macropodhq/go.uuid"
"github.com/foo/bar/entities"
"github.com/foo/bar/fdb"
"github.com/foo/bar/security"
"github.com/foo/simplelog"
)

My generated files have imports looking like this:

import (
"encoding/json"
"strings"

"github.com/facebookgo/stackerr"
uuid "github.com/macropodhq/go.uuid"
"github.com/foo/bar/entities"
"github.com/foo/bar/fdb"
"github.com/foo/bar/security"
"github.com/foo/simplelog"
)

You can see that "errors" has been removed (thus preventing my code from compiling), and "github.com/macropodhq/go.uuid" has been renamed to "uuid" (I didn't ask for it, but OK). Furthermore it has decided to replace the custom json package we use with the standard "Go encoding/json" package. I guess genny is auto-fixing the imports section - but it's doing it wrongly.

@Crevil
Copy link
Contributor

Crevil commented Aug 15, 2017

We are seeing similar behaviour with the packages errors and github.com/pkg/errors.
Are there any means to make sure the imports stay the same?

@pdrum pdrum added the bug label Sep 3, 2018
@pdrum pdrum added this to the 1.0.1 milestone Sep 3, 2018
@eloff
Copy link

eloff commented Dec 24, 2019

I guess that it's using goimports or some such and there is ambiguity between two packages on your system, e.g. errors and github.com/pkg/errors so it does nothing in that case. It would be better if it just copies the imports verbatim and removes the import to genny (if unused).

@Antonboom
Copy link

golang/go#44737

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants