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

errors when using import alias, zap package since version 0.3.0 #60

Closed
brandon-lango opened this issue Mar 24, 2022 · 6 comments
Closed
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@brandon-lango
Copy link

brandon-lango commented Mar 24, 2022

We are using gci as part of golangci-lint. Ever since version 0.3.0, we have been getting errors where previous versions have worked.

This error seems like it's expecting everything to import from github.com, however we use zap which comes from go.uber.org.

Expected 'i', Found 'o'
"go.uber.org/zap"

We also get this, which seems to be related to using aliases

Expected '"', Found 'l'
log "github.com/sirupsen/logrus"

This version also seems to not like blank lines between our third party libraries and internal imports.
Expected '\t', Found '\n'

@daixiang0
Copy link
Owner

Could you try latest version?

@brandon-lango
Copy link
Author

Could you try latest version?

I'm using the latest version of golangci-lint, which includes gci 0.3.2. golangci/golangci-lint#2640

I'm not sure when they will update to 0.3.3, but it doesn't look like that version has fixes for these issues.

@daixiang0 daixiang0 added bug Something isn't working help wanted Extra attention is needed labels Mar 25, 2022
@ngehrsitz
Copy link
Contributor

@brandon-lango Could you please specify the exact command that you ran gci with and upload the affected files so that I can try to reproduce the issue. Only the import section is relevant you can remove everything else.

@brandon-lango
Copy link
Author

Here are a few examples. It seems to fail everywhere there is an import alias or we use the zap package. I'm running gci as a part to golangci-lint, not as a standalone command. We are using all the default settings for gci.

Expected 'i', Found 'o' at pkg/mt/infra/providers/onedrive/download.go[line 9,col 4] (gci)
"go.uber.org/zap"

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"sync"

	"go.uber.org/zap"
)

Expected '\t', Found '\n' at pkg/mt/infra/providers/externalstorage/goroutines.go[line 5,col 1] (gci)

import (
	"github.com/hashicorp/go-multierror"

	mtCommand "github.com/langomobiledev/lango/pkg/mt/app/command"
	"github.com/langomobiledev/lango/pkg/mt/domain/filestorage"
)

Expected '"', Found 'l' at pkg/auth/infra/providers/cognito/register.go[line 11,col 2] (gci)
log "github.com/sirupsen/logrus"

import (
	"context"
	"errors"
	"fmt"

	"github.com/aws/aws-sdk-go-v2/aws"
	cognito "github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider"
	"github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider/types"
	log "github.com/sirupsen/logrus"

	"github.com/langomobiledev/lango/pkg/auth/domain/users"
)

@daixiang0
Copy link
Owner

Please add prefix to test.

@NicklasWallgren
Copy link

I've got this issue as well with golangci-lint v1.46.2

infrastructure/database/database.go:7:2: Expected '"', Found 'g' at infrastructure/database/database.go[line 7,col 2] (gci)
        gormTrace "gopkg.in/DataDog/dd-trace-go.v1/contrib/gorm.io/gorm.v1"
        ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants