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

goimports: remove unused package from the list #41346

Closed
markelog opened this issue Sep 11, 2020 · 4 comments
Closed

goimports: remove unused package from the list #41346

markelog opened this issue Sep 11, 2020 · 4 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@markelog
Copy link

markelog commented Sep 11, 2020

What version of Go are you using (go version)?

$ go version
go version go1.14.1 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
❯ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/markelog/Library/Caches/go-build"
GOENV="/Users/markelog/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/markelog/Workspace/gocode"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/markelog/.eclectica/versions/go/current"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/markelog/.eclectica/versions/go/current/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/markelog/Workspace/rekki/go/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/13/h78kw1v138s_th0qb_rc4gzr0000gn/T/go-build649053730=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

In my company we are using github.com/volatiletech/sqlboiler package, but because it was lacking some feature (or bug I don't recall), we forked it and fixed it ourselves. Provided the fix to upstream too, it was merged. But now, every time I use
github.com/volatiletech/sqlboiler/queries/qm package, goimports adds github.com/rekki/sqlboiler/boil/qm instead. I would like to have an ability for goimports to not used outdated packages with same name

What did you expect to see?

github.com/volatiletech/sqlboiler/queries/qm is added

What did you see instead?

add github.com/rekki/sqlboiler/boil/qm instead

@heschi
Copy link
Contributor

heschi commented Sep 11, 2020

In general, when using modules, goimports should prefer packages that are already in your module's deps over ones that aren't. Please verify that github.com/rekki/sqlboiler isn't in your project's go.mod. If it's not, please show the output of goimports -v when it adds the unwanted import.

@heschi heschi added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Sep 11, 2020
@markelog
Copy link
Author

I don't see it in the go.mod nor in go.sum.
Here is the relevant parts of goimports -v output

2020/09/14 17:20:28.840394 qm candidate 1/4: github.com/rekki/sqlboiler/boil/qm in /Users/markelog/Workspace/gocode/pkg/mod/github.com/rekki/sqlboiler@v1.0.0/boil/qm 2020/09/14 17:20:28.840426 qm candidate 2/4: github.com/rekki/sqlboiler/queries/qm in /Users/markelog/Workspace/gocode/pkg/mod/github.com/rekki/sqlboiler@v3.6.1+incompatible/queries/qm 2020/09/14 17:20:28.840428 qm candidate 3/4: github.com/volatiletech/sqlboiler/boil/qm in /Users/markelog/Workspace/gocode/pkg/mod/github.com/volatiletech/sqlboiler@v1.0.0/boil/qm 2020/09/14 17:20:28.840430 qm candidate 4/4: github.com/volatiletech/sqlboiler/queries/qm in /Users/markelog/Workspace/gocode/pkg/mod/github.com/volatiletech/sqlboiler@v3.7.1+incompatible/queries/qm 2020/09/14 17:20:28.840460 loading exports in dir /Users/markelog/Workspace/gocode/pkg/mod/github.com/volatiletech/sqlboiler@v3.7.1+incompatible/queries/qm (seeking package qm) 2020/09/14 17:20:28.840498 loading exports in dir /Users/markelog/Workspace/gocode/pkg/mod/github.com/rekki/sqlboiler@v3.6.1+incompatible/queries/qm (seeking package qm) 2020/09/14 17:20:28.840540 loading exports in dir /Users/markelog/Workspace/gocode/pkg/mod/github.com/volatiletech/sqlboiler@v1.0.0/boil/qm (seeking package qm) 2020/09/14 17:20:28.840587 loading exports in dir /Users/markelog/Workspace/gocode/pkg/mod/github.com/rekki/sqlboiler@v1.0.0/boil/qm (seeking package qm) 2020/09/14 17:20:28.840920 loaded exports in dir /Users/markelog/Workspace/gocode/pkg/mod/github.com/rekki/sqlboiler@v1.0.0/boil/qm (package qm): And, AndIn, Apply, For, From, GroupBy, Having, InnerJoin, Limit, Load, Offset, Or, OrIn, OrderBy, QueryMod, SQL, Select, Where, WhereIn 2020/09/14 17:20:28.840923 loaded exports in dir /Users/markelog/Workspace/gocode/pkg/mod/github.com/volatiletech/sqlboiler@v1.0.0/boil/qm (package qm): And, AndIn, Apply, For, From, GroupBy, Having, InnerJoin, Limit, Load, Offset, Or, OrIn, OrderBy, QueryMod, SQL, Select, Where, WhereIn 2020/09/14 17:20:28.841145 loaded exports in dir /Users/markelog/Workspace/gocode/pkg/mod/github.com/rekki/sqlboiler@v3.6.1+incompatible/queries/qm (package qm): And, AndIn, Apply, Expr, For, From, GroupBy, Having, InnerJoin, Limit, Load, Offset, Or, Or2, OrIn, OrderBy, QueryMod, QueryModFunc, Rels, SQL, Select, Where, WhereIn, With 2020/09/14 17:20:28.841149 loaded exports in dir /Users/markelog/Workspace/gocode/pkg/mod/github.com/volatiletech/sqlboiler@v3.7.1+incompatible/queries/qm (package qm): And, AndIn, Apply, Distinct, Expr, For, From, FullOuterJoin, GroupBy, Having, InnerJoin, LeftOuterJoin, Limit, Load, Offset, Or, Or2, OrIn, OrderBy, QueryMod, QueryModFunc, Rels, RightOuterJoin, SQL, Select, Where, WhereIn, With package emails

import (
"fmt"
"sort"
"strconv"
"time"

"github.com/jmoiron/sqlx"
iq "github.com/rekki/go-query"
analyzer "github.com/rekki/go-query-analyze"
index "github.com/rekki/go-query-index"
models "github.com/rekki/go/pkg/model/order"
"github.com/rekki/go/pkg/rekki/log"
"github.com/rekki/sqlboiler/boil/qm"
"github.com/volatiletech/null"
"github.com/volatiletech/sqlboiler/boil"
"github.com/volatiletech/sqlboiler/types"

)

@markelog
Copy link
Author

markelog commented Sep 14, 2020

After executing sudo rm -rf $GOPATH/pkg/mod/github.com/rekki/sqlboiler@v* then restarting an editor, the issue seemed to went away

@heschi
Copy link
Contributor

heschi commented Sep 14, 2020

Sorry, this is actually a duplicate of #36077. Clearing your module cache is the only option for now.

@heschi heschi closed this as completed Sep 14, 2020
@golang golang locked and limited conversation to collaborators Sep 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants