incu6us / goimports-reviser

Right imports sorting & code formatting tool (goimports alternative)
MIT License
607 stars 72 forks source link

imports error: tools file for go install command #92

Open sioncojp opened 2 years ago

sioncojp commented 2 years ago
$ 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

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/v3@v3.3.0/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?

haunt98 commented 2 years ago

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