Skip to content

embed: 1.17 rejects types with underlying type []byte #47735

@tnozicka

Description

@tnozicka

What version of Go are you using (go version)?

$ go version
go version go1.17 linux/amd64

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/tnozicka/.cache/go-build"
GOENV="/home/tnozicka/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/tnozicka/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/tnozicka/go"
GOPRIVATE=""
GOPROXY="direct"
GOROOT="/home/tnozicka/lib/go1.17"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/home/tnozicka/lib/go1.17/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/tnozicka/go/src/github.com/scylladb/scylla-operator/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-build318278898=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Updated go from 1.16.7 to 1.17 and the following code stopped compiling

var (
	//go:embed "basic.scyllacluster.yaml"
	BasicScyllaCluster ScyllaCluster
)

type ScyllaCluster []byte

func (sc ScyllaCluster) ReadOrFail() *scyllav1.ScyllaCluster {
	obj, _, err := scheme.Codecs.UniversalDeserializer().Decode(sc, nil, nil)
	o.Expect(err).NotTo(o.HaveOccurred())

	return obj.(*scyllav1.ScyllaCluster)
}

What did you expect to see?

No compile error as it was with 1.16.7 (and previous versions).

What did you see instead?

go:embed cannot apply to var of type ScyllaCluster

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions