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

go get error "cannot use promoted field BasicHandle.DecodeOptions.RawToString" #9096

Closed
alexpasen opened this issue Nov 4, 2020 · 8 comments
Labels
theme/connect Anything related to Consul Connect, Service Mesh, Side Car Proxies theme/go-modules Go modules related changes

Comments

@alexpasen
Copy link

alexpasen commented Nov 4, 2020

Overview of the Issue

On getting package github.com/hashicorp/consul/connect have error.

go get -u github.com/hashicorp/consul/connect
go: finding golang.org/x/sys latest
go: finding golang.org/x/crypto latest
go: finding github.com/hashicorp/yamux latest
go: finding golang.org/x/time latest
go: finding golang.org/x/net latest
go: finding github.com/tv42/httpunix latest
go: finding gopkg.in/yaml.v3 latest
go: finding github.com/sean-/seed latest
 github.com/hashicorp/consul/agent/structs
..\..\..\pkg\mod\github.com\hashicorp\consul@v1.8.5\agent\structs\structs.go:2253:2: cannot use promoted field BasicHandle.Dec
odeOptions.RawToString in struct literal of type codec.MsgpackHandle

Reproduction Steps

  • go mod init
  • go get -u github.com/hashicorp/consul/api
  • go get -u github.com/hashicorp/consul/connect

Operating system and Environment details

  • Ubuntu go version go1.13.8 linux/amd64
  • Windows go version go1.13.5 windows/amd64
  • Jetbrains Go modules integration (vgo) enabled on both systems (Using Jetbrains Golang as IDE)

Windows env

C:\Users\pasenyukaa\Documents\Projects\go\src\company.com\tsp-cs>go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\pasenyukaa\AppData\Local\go-build
set GOENV=C:\Users\pasenyukaa\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GONOPROXY=*company.com
set GONOSUMDB=*company.com
set GOOS=windows
set GOPATH=C:\Users\pasenyukaa\Documents\Projects\go;C:\Go;C:\Users\pasenyukaa\go
set GOPRIVATE=*company.com
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\pasenyukaa\Documents\Projects\go\src\company.com\tsp-cs\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\PASENY~
2\AppData\Local\Temp\go-build253460462=/tmp/go-build -gno-record-gcc-switches

Ubuntu env

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/pasenyukaa/.cache/go-build"
GOENV="/home/pasenyukaa/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/pasenyukaa/Projects/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib/go-1.13"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.13/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/pasenyukaa/Projects/go/src/company.com/tsp-cs/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build492628415=/tmp/go-build -gno-record-gcc-switches"
@nadilas
Copy link

nadilas commented Nov 17, 2020

Same here

@jsosulska jsosulska added theme/go-modules Go modules related changes theme/connect Anything related to Consul Connect, Service Mesh, Side Car Proxies labels Nov 24, 2020
@vmee
Copy link

vmee commented Dec 17, 2020

same here

@waeljammal
Copy link

Same

@blake
Copy link
Member

blake commented Jan 26, 2021

This error seems to be caused by a certain dependency being updated when running go get -u which breaks compatibility with other libraries. I'm not sure of the exact cause. I'll let someone from Consul engineering comment on that.

I was, however, successfully able to build a very basic Connect native client with the code, and build steps.

package main

import (
    "github.com/hashicorp/consul/api"
    "github.com/hashicorp/consul/connect"
    "net/http"
)

func main() {
    // Create a Consul API client
    client, _ := api.NewClient(api.DefaultConfig())

    // Create an instance representing this service. "my-service" is the
    // name of _this_ service. The service should be cleaned up via Close.
    svc, _ := connect.NewService("my-service", client)
    defer svc.Close()

    // Creating an HTTP server that serves via Connect
    server := &http.Server{
        Addr:      ":8080",
        TLSConfig: svc.ServerTLSConfig(),
        // ... other standard fields
    }

    // Serve!
    server.ListenAndServeTLS("", "")
}

Build steps

  1. mkdir native-go-integration && $ cd native-go-integration
  2. Save above file into main.go.
  3.  $ go mod init connetclient
     go: creating new go.mod: module connetclient
    
     $ go get
     go: finding module for package github.com/hashicorp/consul/api
     go: finding module for package github.com/hashicorp/consul/connect
     go: found github.com/hashicorp/consul/api in github.com/hashicorp/consul/api v1.8.1
     go: found github.com/hashicorp/consul/connect in github.com/hashicorp/consul v1.9.2
    
     $ go build
     $ ./connectclient
     ./connectclient
     2021-01-21T13:19:37.468-0800 [ERROR] connect.watch: Watch errored: service=my-service type=connect_roots error="Get "http://127.0.0.1:8500/v1/agent/connect/ca/roots": dial tcp 127.0.0.1:8500: connect: connection refused" retry=5s
     2021-01-21T13:19:37.468-0800 [ERROR] connect.watch: Watch errored: service=my-service type=connect_leaf error="Get "http://127.0.0.1:8500/v1/agent/connect/ca/leaf/my-service": dial tcp 127.0.0.1:8500: connect: connection refused" retry=5s

As you can see the client successfully compiles and tries to connect to Consul. Note that I did not set up a Consul server as part of this quick test, hence the connection refused errors.

Would you folks mind testing and reporting whether the above build steps work for your use case? If not, could you please share a bit more detail on your specific build steps so we can better debug?

Thank you.

@pterjan
Copy link

pterjan commented Jan 26, 2021

The problem is in go-msgpack which has a very strange v1.1.5 release as I explained in hashicorp/serf#620 (comment) I guess I'll open an issue there but I assumed it would be seen as all of those are from hashicorp

@pterjan
Copy link

pterjan commented Jan 26, 2021

Ah issues are not enabled for go-msgpack.

@rboyer
Copy link
Member

rboyer commented Jan 26, 2021

There is no github.com/hashicorp/consul/connect module, just github.com/hashicorp/consul. If you want to fetch dependencies to add into your go.mod file you will want to avoid using go get -u and use go get. The -u flag will cause all packages to be updated to the latest versions, rather than respect what the relevant go.mod files say:

$ go mod init
$ go get github.com/hashicorp/consul@latest   # <--- this is the main fix
# < create main.go as blake showed above >
$ go mod tidy
$ cat go.mod
module connectclient

go 1.15

require (
	github.com/hashicorp/consul v1.9.2
	github.com/hashicorp/consul/api v1.8.1
)

@alexpasen
Copy link
Author

The problem was in go-msgpack v1.1.5. I can't understand how it appears in go.mod. Probably I tried to fetch something else previously and didn't clean dependencies. After removing go-msgpack package problem went away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/connect Anything related to Consul Connect, Service Mesh, Side Car Proxies theme/go-modules Go modules related changes
Projects
None yet
Development

No branches or pull requests

8 participants