goimports-reviser
goimports-reviser copied to clipboard
imports error: tools file for go install command
$ cat tools.go
// +build tools
package tools
import (
_ "github.com/incu6us/goimports-reviser"
)
This is the file for go install
to keep it from disappearing with go mod tidy
.
See below for details
- https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module
- https://github.com/go-modules-by-example/index/blob/master/010_tools/README.md
Running this file with the -rm-unused
option will result in an error.
$ goimports-reviser -company-prefixes "github.com/xxx" -project-name -rm-unused -imports-order std,company,project,general -file-path tools.go
2022/11/17 10:49:55 internal error: go list gives conflicting information for package github.com/xxx/api [github.com/xxx/api.test]
main.main
/Users/sion_cojp/work/go/pkg/mod/github.com/incu6us/goimports-reviser/[email protected]/main.go:330
runtime.main
/Users/sion_cojp/.goenv/versions/1.18.0/src/runtime/proc.go:250
runtime.goexit
/Users/sion_cojp/.goenv/versions/1.18.0/src/runtime/asm_arm64.s:1259
Is there any way to avoid this error?
I also get this error too, with build.go
exist
//go:build tools
// +build tools
package main
import (
_ "github.com/envoyproxy/protoc-gen-validate"
_ "github.com/golang/protobuf/protoc-gen-go"
_ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway"
_ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger"
_ "github.com/kei2100/protoc-gen-marshal-zap/plugin/protoc-gen-marshal-zap"
)
Looks like we need to ignore build tools