Closed amokkara closed 2 years ago
That looks more like an issue of the version of golangci-lint you are using. We use golangci-lint in our CI and it passes on the bindings.
@vrothberg This is my go code:
import (
"context"
"fmt"
"os"
"github.com/containers/podman/v4/pkg/bindings"
"github.com/containers/podman/v4/pkg/bindings/images"
)
func main() {
sock_dir := os.Getenv("XDG_RUNTIME_DIR")
if sock_dir == "" {
sock_dir = "/var/run"
}
socket := "unix:" + sock_dir + "/podman/podman.sock"
conn, err := bindings.NewConnection(context.Background(), socket)
if err != nil {
fmt.Println(fmt.Sprintf("Unable to read podman socket at %v. Checking alternate location", socket))
socket = "unix://run/podman/podman.sock"
conn, err = bindings.NewConnection(context.Background(), socket)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}
imageSummary, err := images.List(conn, &images.ListOptions{})
if err != nil {
fmt.Println(err)
os.Exit(1)
}
fmt.Println(imageSummary)
}
Its throwing below error
/aditya/podman-poc # ../bin/golangci-lint run --timeout 2m
WARN [runner] Can't run linter goanalysis_metalinter: buildir: failed to load package unshare: could not load export data: no export data for "github.com/containers/storage/pkg/unshare"
ERRO Running error: 1 error occurred:
* can't run linter goanalysis_metalinter: buildir: failed to load package unshare: could not load export data: no export data for github.com/containers/storage/pkg/unshare ```
I'm using latest golintci -> 1.47.3
I'm just following the examples given in repo. And i dont feel its related to golintci version.
Thanks for providing the details. I could reproduce. In order to resolve the issue, make sure to run go mod tidy
. That'll resolve the proper dependencies and golangci-lint will work aferwards.
@vrothberg i already tried that too. It doesnt work (in my case). really not sure where its going wrong. Its just simple code!!!
~/aditya/podman-poc # go mod tidy
~/aditya/podman-poc # ../bin/golangci-lint run --timeout 2m WARN [runner] Can't run linter goanalysis_metalinter: buildir: failed to load package unshare: could not load export data: no export data for "github.com/containers/storage/pkg/unshare" ERRO Running error: 1 error occurred:
~/aditya/podman-poc # CGO_ENABLED=0 ../bin/golangci-lint run --timeout 2m WARN [runner] Can't run linter goanalysis_metalinter: buildir: failed to load package signature: could not load export data: no export data for "github.com/containers/image/v5/signature" ERRO Running error: 1 error occurred:
what is the golint version you tried with?
I used version v1.47.1 with go1.19.1.
Can you try a go mod vendor
?
@vrothberg could you share the go.mod file in your setup please.
module foo.com
go 1.19
require github.com/containers/podman/v4 v4.2.1
require (
github.com/BurntSushi/toml v1.2.0 // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/Microsoft/hcsshim v0.9.3 // indirect
github.com/VividCortex/ewma v1.2.0 // indirect
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect
github.com/cilium/ebpf v0.7.0 // indirect
github.com/containerd/cgroups v1.0.3 // indirect
github.com/containerd/containerd v1.6.6 // indirect
github.com/containerd/stargz-snapshotter/estargz v0.12.0 // indirect
github.com/containers/buildah v1.27.0 // indirect
github.com/containers/common v0.49.1 // indirect
github.com/containers/image/v5 v5.22.0 // indirect
github.com/containers/libtrust v0.0.0-20200511145503-9c3a6c22cd9a // indirect
github.com/containers/ocicrypt v1.1.5 // indirect
github.com/containers/psgo v1.7.3 // indirect
github.com/containers/storage v1.42.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/cyphar/filepath-securejoin v0.2.3 // indirect
github.com/disiqueira/gotree/v3 v3.0.2 // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/docker v20.10.17+incompatible // indirect
github.com/docker/docker-credential-helpers v0.6.4 // indirect
github.com/docker/go-connections v0.4.1-0.20210727194412-58542c764a11 // indirect
github.com/docker/go-metrics v0.0.1 // indirect
github.com/docker/go-units v0.4.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-containerregistry v0.10.0 // indirect
github.com/google/go-intervals v0.0.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/jinzhu/copier v0.3.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.15.9 // indirect
github.com/klauspost/pgzip v1.2.5 // indirect
github.com/letsencrypt/boulder v0.0.0-20220331220046-b23ab962616e // indirect
github.com/manifoldco/promptui v0.9.0 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mattn/go-shellwords v1.0.12 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/miekg/pkcs11 v1.1.1 // indirect
github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible // indirect
github.com/moby/sys/mountinfo v0.6.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.3-0.20220114050600-8b9d41f48198 // indirect
github.com/opencontainers/runc v1.1.3 // indirect
github.com/opencontainers/runtime-spec v1.0.3-0.20211214071223-8958f93039ab // indirect
github.com/opencontainers/runtime-tools v0.9.1-0.20220714195903-17b3287fafb7 // indirect
github.com/opencontainers/selinux v1.10.1 // indirect
github.com/ostreedev/ostree-go v0.0.0-20210805093236-719684c64e4f // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/proglottis/gpgme v0.1.3 // indirect
github.com/prometheus/client_golang v1.12.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/sigstore/sigstore v1.3.1-0.20220629021053-b95fc0d626c1 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stefanberger/go-pkcs11uri v0.0.0-20201008174630-78d3cae3a980 // indirect
github.com/sylabs/sif/v2 v2.7.1 // indirect
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 // indirect
github.com/tchap/go-patricia v2.3.0+incompatible // indirect
github.com/theupdateframework/go-tuf v0.3.1 // indirect
github.com/titanous/rocacheck v0.0.0-20171023193734-afe73141d399 // indirect
github.com/ulikunitz/xz v0.5.10 // indirect
github.com/vbatts/tar-split v0.11.2 // indirect
github.com/vbauerster/mpb/v7 v7.4.2 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
go.etcd.io/bbolt v1.3.6 // indirect
go.mozilla.org/pkcs7 v0.0.0-20200128120323-432b2356ecb1 // indirect
go.opencensus.io v0.23.0 // indirect
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect
golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e // indirect
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f // indirect
golang.org/x/sys v0.0.0-20220823224334-20c2bfdbfe24 // indirect
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20220624142145-8cd45d7dbd1f // indirect
google.golang.org/grpc v1.47.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
**~/aditya/podman_test # CGO_ENABLED=0 ./bin/golangci-lint run --timeout 5m WARN [runner] Can't run linter goanalysis_metalinter: buildssa: failed to load package images: could not load export data: no export data for "github.com/containers/podman/v4/pkg/bindings/images" ERRO Running error: 1 error occurred:
Not seeing this issue if use v3/pkg/bindings/images
Steps to reproduce the issue:
Describe the results you received:
Describe the results you expected:
Additional information you deem important (e.g. issue happens only occasionally):
Output of
podman version
:Output of
podman info
:Package info (e.g. output of
rpm -q podman
orapt list podman
):Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)
Yes/No
Additional environment details (AWS, VirtualBox, physical, etc.):
go.mod file:
require ( github.com/containers/podman/v4 v4.2.1 github.com/docker/docker v20.10.17+incompatible github.com/go-logr/logr v1.2.2