Open caevv opened 3 years ago
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.
I'm facing the same issue with golangci-lint v1.41.1
. I'm only using goimports
though.
We're also hitting an issue where gci
removes imports, breaking the build.
Edit: In our case, the import
section contained the following two lines at the bottom, and removing them causes gci to no longer erroneously remove the import:
import (
// …
//nolint
//+kubebuilder:scaffold:imports
)
Welcome
Description of the problem
When I have enabled GCI and goimports and run with
--fix
certain packages are being removed.Now if I run
gci
andgoimports
manually, the commands fix the issues and does not remove the packages, later on runninggolangci-lint run --fix
nothing happens.Packages being removed for the provided example:
Running with
--fix -v
:Version of golangci-lint
Configuration file
Go environment
Verbose output of running
Code example or link to a public repository
EDIT
pkg/logger/logger.go
```go package logger import ( "log" "github.com/golangci/sandbox/pkg/logs" "go.uber.org/zap" ) func New() *zap.Logger { logger, err := logs.NewZap("dev") if err != nil { log.Fatalf("unable to build zap logger: %v", err) } return logger } ```pkg/logs/logs.go
```go package logs import "go.uber.org/zap" func NewZap(s string) (*zap.Logger, error) { return nil, nil } ```pkg/service/service.go
```go package service import ( "encoding/json" "fmt" "go.uber.org/zap" "github.com/golangci/sandbox/pkg/logger" ) type Service struct { logger *zap.Logger } func New() *Service { p := Service{} p.logger = logger.New() return &p } func (p *Service) Method(d string) error { p.logger.Error("sample", zap.String("key", "value")) fmt.Println("test") _ = json.Encoder{} return nil } ```.golangci.yml
```yaml linters-settings: gci: local-prefixes: github.com/golangci/sandbox goimports: local-prefixes: github.com/golangci/sandbox linters: disable-all: true enable: - goimports - gci ```