modules usage help

279 views
Skip to first unread message

T L

unread,
Apr 1, 2019, 5:22:57 AM4/1/19
to golang-nuts
I created a new project.

The main.go file

package main

import "github.com/projectcalico/libcalico-go/lib/apiconfig"

func main() {
    var _ = aouconfig.LoadClientConfig
}

The go.mod.file

module a.b.c/ddd

require github.com/projectcalico/libcalico-go latest

go 1.12

Build it:

After the build, the go.mod file is modified to

module a.b.c/ddd

require github.com/projectcalico/libcalico-go v1.7.3

go 1.12

Building it again gets the same error output.

How to use this package in vgo mode?

Jakob Borg

unread,
Apr 1, 2019, 9:01:28 AM4/1/19
to T L, golang-nuts
On 1 Apr 2019, at 11:22, T L <tapi...@gmail.com> wrote:

How to use this package in vgo mode?

go mod init a.b.c/ddd

The problem is that their latest non-prerelease tag is v1.7.3, which is several years old and doesn’t contain the package you want to import.

//jb

T L

unread,
Apr 1, 2019, 9:42:21 AM4/1/19
to golang-nuts
Got it. Thanks very much! 

T L

unread,
Apr 2, 2019, 12:33:41 AM4/2/19
to golang-nuts


On Monday, April 1, 2019 at 9:01:28 AM UTC-4, Jakob Borg wrote:
There are still some problems:

$ cat main.go
package main

import _ "github.com/projectcalico/libcalico-go/lib/apiconfig"
import _ "github.com/projectcalico/libcalico-go/lib/clientv3"

func main() {
   
}

$ cat go.mod
module a.b.c/ddd

require (
    github.com/projectcalico/libcalico-go v3.7.0-0.dev+incompatible
)

go 1.12

$ go build
go: finding github.com/coreos/etcd/clientv3 latest
go: finding github.com/coreos/etcd/mvcc/mvccpb latest
go: finding github.com/coreos/etcd/mvcc latest
go: finding k8s.io/apimachinery/pkg/runtime/schema latest
go: finding k8s.io/apimachinery/pkg/runtime/serializer latest
go: finding k8s.io/apimachinery/pkg/runtime latest
go: finding k8s.io/apimachinery/pkg/apis/meta latest
go: finding k8s.io/apimachinery/pkg/util/validation latest
go: finding k8s.io/apimachinery/pkg/util/uuid latest
go: finding k8s.io/api/core latest
go: finding k8s.io/client-go/kubernetes latest
go: finding k8s.io/client-go/plugin/pkg/client/auth latest
go: finding k8s.io/client-go/tools/clientcmd latest
go: finding k8s.io/apimachinery/pkg latest
go: finding k8s.io/apimachinery/pkg/apis latest
go: finding k8s.io/apimachinery/pkg/util latest
go: finding k8s.io/api latest
go: finding github.com/coreos/etcd/pkg/transport latest
go: finding github.com/coreos/etcd/pkg latest
go: finding k8s.io/apimachinery latest
go: finding k8s.io/client-go/plugin/pkg/client latest
go: finding k8s.io/client-go/tools latest
go: finding k8s.io/apimachinery/pkg/api/meta latest
go: finding k8s.io/apimachinery/pkg/types latest
go: finding k8s.io/apimachinery/pkg/util/intstr latest
go: finding k8s.io/apimachinery/pkg/api/errors latest
go: finding k8s.io/client-go/plugin/pkg latest
go: finding k8s.io/apimachinery/pkg/api latest
go: finding k8s.io/api/networking latest
go: finding k8s.io/apimachinery/pkg/watch latest
go: finding k8s.io/client-go/plugin latest
go: finding k8s.io/client-go/tools/cache latest
go: finding k8s.io/client-go/rest latest
go: finding k8s.io/apimachinery/pkg/fields latest
go: finding k8s.io/client-go/kubernetes/scheme latest
go: finding github.com/projectcalico/go-yaml-wrapper latest
go: finding golang.org/x/net/http2 latest
go: finding golang.org/x/net latest
go: finding github.com/projectcalico/go-json/json latest
go: finding github.com/projectcalico/go-yaml latest
go: finding github.com/projectcalico/go-json latest
go: finding k8s.io/api/admissionregistration/v1alpha1 latest
go: finding github.com/Azure/go-autorest/autorest latest
go: finding github.com/gogo/protobuf/proto latest
go: finding github.com/gogo/protobuf/gogoproto latest
go: finding github.com/Azure/go-autorest/autorest/adal latest
go: finding k8s.io/api/admissionregistration latest
go: finding github.com/Azure/go-autorest/autorest/azure latest
go: finding github.com/golang/protobuf/proto latest
go: finding github.com/google/gofuzz latest
go: finding golang.org/x/net/context latest
go: finding github.com/gogo/protobuf/sortkeys latest
go: finding golang.org/x/oauth2 latest
go: finding github.com/googleapis/gnostic/OpenAPIv2 latest
go: finding golang.org/x/oauth2/google latest
go: finding github.com/gregjones/httpcache/diskcache latest
go: finding github.com/gregjones/httpcache latest
go: finding google.golang.org/grpc/codes latest
go: finding google.golang.org/grpc/credentials latest
go: finding google.golang.org/grpc/grpclog latest
go: finding google.golang.org/grpc/metadata latest
go: finding google.golang.org/grpc/status latest
go: finding google.golang.org/grpc/keepalive latest
go: finding github.com/gophercloud/gophercloud/openstack latest
go: finding github.com/gophercloud/gophercloud latest
go: finding google.golang.org/grpc/health/grpc_health_v1 latest
go: finding google.golang.org/grpc/health latest
go: finding golang.org/x/time/rate latest
go: finding golang.org/x/time latest
go: finding github.com/modern-go/concurrent latest
go: finding go.opencensus.io/plugin/ochttp latest
go: finding go.opencensus.io/stats/view latest
go: finding go.opencensus.io/trace latest
go: finding go.opencensus.io/plugin/ochttp/propagation/tracecontext latest
go: finding go.opencensus.io/plugin latest
go: finding go.opencensus.io/stats latest
go: finding go.opencensus.io/plugin/ochttp/propagation latest
go: finding github.com/grpc-ecosystem/grpc-gateway/runtime latest
go: finding github.com/grpc-ecosystem/grpc-gateway/utilities latest
build a.b.c/ddd: cannot load k8s.io/api/admissionregistration/v1alpha1: cannot find module providing package k8s.io/api/admissionregistration/v1alpha1


It looks the problem is the same as the old one.
It should be possible that I can find the proper versions for the indirect dependencies.
The libcalico-go project uses glide as the dependency tool.
There is a glide.lock file.
The go command should get the indirect dependency version there,
instead of failing to exit and letting uses to find the proper versions.

T L

unread,
Apr 2, 2019, 12:36:27 AM4/2/19
to golang-nuts
Without godep/glide/etc import built-in, it would be a big obstacle to use some modules (which not using vgo currently) with many indirect dependencies.

T L

unread,
Apr 2, 2019, 5:31:51 AM4/2/19
to golang-nuts


and this is the go.mod file after running go build:

module a.b.c/ddd

require (
    contrib.go.opencensus.io/exporter/ocagent v0.4.10 // indirect
    github.com/Azure/go-autorest v11.7.0+incompatible // indirect
    github.com/coreos/bbolt v1.3.2 // indirect
    github.com/coreos/etcd v3.3.12+incompatible // indirect
    github.com/coreos/go-semver v0.2.0 // indirect
    github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e // indirect
    github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
    github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
    github.com/go-playground/locales v0.12.1 // indirect
    github.com/go-playground/universal-translator v0.16.0 // indirect
    github.com/gogo/protobuf v1.2.1 // indirect
    github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect
    github.com/golang/mock v1.2.0 // indirect
    github.com/google/btree v1.0.0 // indirect
    github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect
    github.com/google/uuid v1.1.1 // indirect
    github.com/googleapis/gnostic v0.2.0 // indirect
    github.com/gophercloud/gophercloud v0.0.0-20190330013820-4d3066f119fa // indirect
    github.com/gorilla/websocket v1.4.0 // indirect
    github.com/gregjones/httpcache v0.0.0-20190212212710-3befbb6ad0cc // indirect
    github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 // indirect
    github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
    github.com/grpc-ecosystem/grpc-gateway v1.8.5 // indirect
    github.com/hashicorp/golang-lru v0.5.1 // indirect
    github.com/imdario/mergo v0.3.7 // indirect
    github.com/jonboulle/clockwork v0.1.0 // indirect
    github.com/json-iterator/go v1.1.6 // indirect
    github.com/kelseyhightower/envconfig v1.3.0 // indirect
    github.com/leodido/go-urn v1.1.0 // indirect
    github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
    github.com/modern-go/reflect2 v1.0.1 // indirect
    github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
    github.com/projectcalico/go-json v0.0.0-20161128004156-6219dc7339ba // indirect
    github.com/projectcalico/go-yaml v0.0.0-20161201183616-955bc3e451ef // indirect
    github.com/projectcalico/go-yaml-wrapper v0.0.0-20161127220527-598e54215bee // indirect
    github.com/projectcalico/libcalico-go v3.7.0-0.dev+incompatible
    github.com/satori/go.uuid v1.2.0 // indirect
    github.com/sirupsen/logrus v1.4.0 // indirect
    github.com/soheilhy/cmux v0.1.4 // indirect
    github.com/spf13/pflag v1.0.3 // indirect
    github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
    github.com/ugorji/go/codec v0.0.0-20190320090025-2dc34c0b8780 // indirect
    github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
    go.etcd.io/bbolt v1.3.2 // indirect
    go.opencensus.io v0.20.0 // indirect
    go.uber.org/atomic v1.3.2 // indirect
    go.uber.org/multierr v1.1.0 // indirect
    go.uber.org/zap v1.9.1 // indirect
    golang.org/x/net v0.0.0-20190328230028-74de082e2cca // indirect
    golang.org/x/oauth2 v0.0.0-20190319182350-c85d3e98c914 // indirect
    golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect
    gopkg.in/go-playground/assert.v1 v1.2.1 // indirect
    gopkg.in/go-playground/validator.v9 v9.28.0 // indirect
    gopkg.in/inf.v0 v0.9.1 // indirect
    k8s.io/api v0.0.0-20190327184913-92d2ee7fc726 // indirect
    k8s.io/apimachinery v0.0.0-20190402064448-91ffda0f6be2 // indirect
    k8s.io/client-go v10.0.0+incompatible // indirect
    k8s.io/klog v0.2.0 // indirect
    sigs.k8s.io/yaml v1.1.0 // indirect
)

go 1.12

Who can help me on how to specify the version numbers in go.mod file to let the program compile ok?

T L

unread,
Apr 3, 2019, 8:26:26 AM4/3/19
to golang-nuts
I run "go mod init a/bc/xxx" under the "libcal...@v3.7.0-0.dev+incompatible" folder in the module cache directory.
Then I copy the require lines from the generated go.mod file into the "a.b.c/ddd" project.
It compiles ok now.

But the whole experience is really not happy.
Reply all
Reply to author
Forward
0 new messages