Go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28 not working

Hi, I’m struggling to find the reason why this command isn’t working for me. I’m getting the following. Any help greatly appreciated thank you.

…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/compiler/protogen/protogen.go:14:2: package bufio is not in GOROOT (/usr/local/go/src/bufio)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/compiler/protogen/protogen.go:15:2: package bytes is not in GOROOT (/usr/local/go/src/bytes)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/internal/impl/legacy_file.go:9:2: package compress/gzip is not in GOROOT (/usr/local/go/src/compress/gzip)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/internal/detrand/rand.go:13:2: package encoding/binary is not in GOROOT (/usr/local/go/src/encoding/binary)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/internal/impl/legacy_export.go:9:2: package encoding/json is not in GOROOT (/usr/local/go/src/encoding/json)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/cmd/protoc-gen-go/main.go:13:2: package errors is not in GOROOT (/usr/local/go/src/errors)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/cmd/protoc-gen-go/main.go:14:2: package flag is not in GOROOT (/usr/local/go/src/flag)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/cmd/protoc-gen-go/main.go:15:2: package fmt is not in GOROOT (/usr/local/go/src/fmt)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/cmd/protoc-gen-go/internal_gengo/main.go:10:2: package go/ast is not in GOROOT (/usr/local/go/src/go/ast)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/cmd/protoc-gen-go/internal_gengo/main.go:11:2: package go/parser is not in GOROOT (/usr/local/go/src/go/parser)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/compiler/protogen/protogen.go:19:2: package go/printer is not in GOROOT (/usr/local/go/src/go/printer)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/cmd/protoc-gen-go/internal_gengo/main.go:12:2: package go/token is not in GOROOT (/usr/local/go/src/go/token)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/compiler/protogen/protogen.go:21:2: package go/types is not in GOROOT (/usr/local/go/src/go/types)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/internal/impl/legacy_export.go:10:2: package hash/crc32 is not in GOROOT (/usr/local/go/src/hash/crc32)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/internal/detrand/rand.go:14:2: package hash/fnv is not in GOROOT (/usr/local/go/src/hash/fnv)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/encoding/protowire/wire.go:13:2: package io is not in GOROOT (/usr/local/go/src/io)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/internal/impl/legacy_file.go:10:2: package io/ioutil is not in GOROOT (/usr/local/go/src/io/ioutil)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/encoding/protowire/wire.go:14:2: package math is not in GOROOT (/usr/local/go/src/math)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/encoding/protowire/wire.go:15:2: package math/bits is not in GOROOT (/usr/local/go/src/math/bits)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/internal/detrand/rand.go:15:2: package os is not in GOROOT (/usr/local/go/src/os)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/compiler/protogen/protogen.go:24:2: package path is not in GOROOT (/usr/local/go/src/path)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/compiler/protogen/protogen.go:25:2: package path/filepath is not in GOROOT (/usr/local/go/src/path/filepath)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/proto/equal.go:10:2: package reflect is not in GOROOT (/usr/local/go/src/reflect)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/internal/encoding/text/decode.go:11:2: package regexp is not in GOROOT (/usr/local/go/src/regexp)
package google.golang.org/protobuf/cmd/protoc-gen-go: cannot find package
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/internal/order/range.go:9:2: package sort is not in GOROOT (/usr/local/go/src/sort)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/reflect/protoreflect/source.go:8:2: package strconv is not in GOROOT (/usr/local/go/src/strconv)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/reflect/protoreflect/proto.go:131:2: package strings is not in GOROOT (/usr/local/go/src/strings)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/internal/pragma/pragma.go:9:8: package sync is not in GOROOT (/usr/local/go/src/sync)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/internal/filedesc/desc.go:11:2: package sync/atomic is not in GOROOT (/usr/local/go/src/sync/atomic)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/internal/strs/strings.go:11:2: package unicode is not in GOROOT (/usr/local/go/src/unicode)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/internal/encoding/text/decode_string.go:12:2: package unicode/utf16 is not in GOROOT (/usr/local/go/src/unicode/utf16)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/internal/strs/strings.go:12:2: package unicode/utf8 is not in GOROOT (/usr/local/go/src/unicode/utf8)
…/…/…/go/pkg/mod/google.golang.org/protobuf@v1.28.0/reflect/protoreflect/value_unsafe.go:11:2: package unsafe is not in GOROOT (/usr/local/go/src/unsafe)

What version of Go do you have installed on the computer you’re running the build from? You can get that by running go version from a Command Prompt/Terminal.

Thanks for your reply Sean. Output from go version is:

go version go1.18 darwin/amd64

And output of go env (if that helps) is: (if I recall I installed it with homebrew on my mac)

GO111MODULE=“on”
GOARCH=“amd64”
GOBIN=“/Users/XXXX/go/bin”
GOCACHE=“/Users/XXXX/Library/Caches/go-build”
GOENV=“/Users/XXXX/Library/Application Support/go/env”
GOEXE=“”
GOEXPERIMENT=“”
GOFLAGS=“”
GOHOSTARCH=“amd64”
GOHOSTOS=“darwin”
GOINSECURE=“”
GOMODCACHE=“/Users/XXXX/go/pkg/mod”
GONOPROXY=“”
GONOSUMDB=“”
GOOS=“darwin”
GOPATH=“/Users/XXXX/go”
GOPRIVATE=“”
GOPROXY=“https://proxy.golang.org,direct”
GOROOT=“/usr/local/Cellar/go/1.18/libexec”
GOSUMDB=“sum.golang.org
GOTMPDIR=“”
GOTOOLDIR=“/usr/local/Cellar/go/1.18/libexec/pkg/tool/darwin_amd64”
GOVCS=“”
GOVERSION=“go1.18”
GCCGO=“gccgo”
GOAMD64=“v1”
AR=“ar”
CC=“clang”
CXX=“clang++”
CGO_ENABLED=“1”
GOMOD=“/dev/null”
GOWORK=“”
CGO_CFLAGS=“-g -O2”
CGO_CPPFLAGS=“”
CGO_CXXFLAGS=“-g -O2”
CGO_FFLAGS=“-g -O2”
CGO_LDFLAGS=“-g -O2”
PKG_CONFIG=“pkg-config”
GOGCCFLAGS=“-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/hq/0vgn198d7v5_kkhc5y8bz8r40000gq/T/go-build3791061883=/tmp/go-build -gno-record-gcc-switches -fno-common”