netobserv / flowlogs-pipeline

Transform flow logs into metrics
Apache License 2.0
73 stars 23 forks source link

Cannot build project with golang 1.18 #150

Closed amorenoz closed 2 years ago

amorenoz commented 2 years ago

There are many linting errors that stop the project from being built/used.

make build
cmd/confgenerator/main.go:27:2: "github.com/json-iterator/go" imported but not used as jsoniter (typecheck)
        jsoniter "github.com/json-iterator/go"
        ^
cmd/flowlogs-pipeline/main.go:28:2: "github.com/json-iterator/go" imported but not used as jsoniter (typecheck)
        jsoniter "github.com/json-iterator/go"
        ^
pkg/confgen/confgen.go:150:8: undeclared name: `yaml` (typecheck)
        err = yaml.Unmarshal(yamlFile, &defFile)
              ^
pkg/confgen/config.go:78:8: undeclared name: `yaml` (typecheck)
        err = yaml.Unmarshal(yamlFile, &config)
              ^
pkg/confgen/flowlogs2metrics_config.go:115:21: undeclared name: `yaml` (typecheck)
        configData, err := yaml.Marshal(&config)
                           ^
pkg/confgen/confgen.go:29:2: "gopkg.in/yaml.v2" imported but not used (typecheck)
        "gopkg.in/yaml.v2"
        ^
pkg/confgen/config.go:25:2: "gopkg.in/yaml.v2" imported but not used (typecheck)
        "gopkg.in/yaml.v2"
        ^
pkg/confgen/flowlogs2metrics_config.go:24:2: "gopkg.in/yaml.v2" imported but not used (typecheck)
        "gopkg.in/yaml.v2"
        ^
pkg/pipeline/pipeline_test.go:25:2: "github.com/netobserv/flowlogs-pipeline/pkg/pipeline/decode" imported but not used (typecheck)
        "github.com/netobserv/flowlogs-pipeline/pkg/pipeline/decode"
        ^
pkg/pipeline/pipeline_test.go:26:2: "github.com/netobserv/flowlogs-pipeline/pkg/pipeline/ingest" imported but not used (typecheck)
        "github.com/netobserv/flowlogs-pipeline/pkg/pipeline/ingest"
        ^
pkg/pipeline/encode/encode_prom.go:21:2: could not import container/list (-: could not load export data: cannot import "container/list" (unstable iexport format version 2, just rebuild compiler and std library), export data is newer version - update tool) (typecheck)
        "container/list"
        ^
pkg/pipeline/transform/transform_network.go:54:25: n.Rules undefined (type *Network has no field or method Rules) (typecheck)
        for _, rule := range n.Rules {
                               ^
pkg/pipeline/transform/connection_tracking/connection_tracking.go:21:2: could not import container/list (-: could not load export data: cannot import "container/list" (unstable iexport format version 2, just rebuild compiler and std library), export data is newer version - update tool) (typecheck)
        "container/list"
        ^
pkg/pipeline/transform/kubernetes/kubernetes_test.go:86:15: informerMock.On undefined (type *InformerMock has no field or method On) (typecheck)
        informerMock.On("GetIndexer", mock.Anything, mock.Anything, mock.Anything).Return(nil)
                     ^
pkg/pipeline/transform/kubernetes/kubernetes.go:28:2: "k8s.io/api/apps/v1" imported but not used as appsv1 (typecheck)
        appsv1 "k8s.io/api/apps/v1"
        ^
pkg/pipeline/transform/location/location.go:54:17: undeclared name: `ip2location` (typecheck)
var locationDB *ip2location.DB
                ^
pkg/pipeline/transform/location/location.go:146:19: undeclared name: `ip2location` (typecheck)
        db, openDBErr := ip2location.OpenDB(DBFileLocation + "/" + DBFilename)
                         ^
pkg/pipeline/transform/location/location_test.go:125:16: undeclared name: `ip2location` (typecheck)
        locationDB = &ip2location.DB{}
                      ^
pkg/pipeline/transform/location/location.go:33:2: "github.com/ip2location/ip2location-go/v9" imported but not used (typecheck)
        "github.com/ip2location/ip2location-go/v9"
        ^
pkg/pipeline/transform/location/location_test.go:31:2: "github.com/ip2location/ip2location-go/v9" imported but not used (typecheck)
        "github.com/ip2location/ip2location-go/v9"
        ^
pkg/pipeline/write/write_loki_test.go:108:5: fe.On undefined (type fakeEmitter has no field or method On) (typecheck)
        fe.On("Handle", mock.Anything, mock.Anything, mock.Anything).Return(nil)
           ^
pkg/pipeline/write/write_loki_test.go:118:5: fe.AssertCalled undefined (type fakeEmitter has no field or method AssertCalled) (typecheck)
        fe.AssertCalled(t, "Handle", model.LabelSet{
           ^
pkg/pipeline/write/write_loki_test.go:124:5: fe.AssertCalled undefined (type fakeEmitter has no field or method AssertCalled) (typecheck)
        fe.AssertCalled(t, "Handle", model.LabelSet{
           ^
pkg/pipeline/write/write_loki_test.go:161:7: fe.On undefined (type fakeEmitter has no field or method On) (typecheck)
                        fe.On("Handle", mock.Anything, mock.Anything, mock.Anything).Return(nil)
                           ^
pkg/pipeline/write/write_loki_test.go:165:7: fe.AssertCalled undefined (type fakeEmitter has no field or method AssertCalled) (typecheck)
                        fe.AssertCalled(t, "Handle", model.LabelSet{},
                           ^
pkg/pipeline/write/write_loki_test.go:204:7: fe.On undefined (type fakeEmitter has no field or method On) (typecheck)
                        fe.On("Handle", mock.Anything, mock.Anything, mock.Anything).Return(nil)
                           ^
make: *** [Makefile:69: lint] Error 1
golangci-lint version
golangci-lint has version 1.39.0 built from 9aea4aee on 2021-03-26T08:02:53Z
github-actions[bot] commented 2 years ago

Congratulations for contributing your first flowlogs-pipeline issue

ronensc commented 2 years ago

Thanks for opening the issue.

I guess this is somehow related to Go's version.

In this repo we use version 1.17. But, when I switched ro 1.18 I received the same errors. I'm not sure why...

I found a similar issue where changing the go version solved the problem: https://github.com/golangci/golangci-lint/issues/2195

@amorenoz Could you please share which go version you use?

amorenoz commented 2 years ago

I use 1.18

eranra commented 2 years ago

https://github.com/golangci/golangci-lint/issues/2649

eranra commented 2 years ago

@amorenoz can you check with 1.17 and see if things work for you?