Golang build error 0x80000034 (2147483700) - go

command I ran: go build -o main
output:
/usr/local/go/pkg/tool/darwin_arm64/link: /usr/local/go/pkg/tool/darwin_arm64/link: combining dwarf failed: unknown load command 0x80000034 (2147483700)
go version: go version go1.16.4 darwin/arm64

Have a look at issue #47269.
load command 0x80000034 corresponds to LC_DYLD_CHAINED_FIXUPS. Support for this load command was added in https://go-review.googlesource.com/c/go/+/312729, which is part of Go 1.17.
You should upgrade to Go 1.17 or above.

As mentioned by #blackgreen, can solve the problem by upgrading to Go 1.17.
However if not wanna upgrade to Go 1.17, can also try to install an AMD version of Go 1.16 and run again. This works for me on my MAC M1.

If you can disable cgo CGO_ENABLED=0 go build -o main it should build with go 1.16

If you are on Mac M1 chip, and if you wanna go 1.16, can also try to install an amd version of the go 1.16. This has been tested and worked fine on my machine.
Reference: https://www.pixelstech.net/article/1637845585-combining-dwarf-failed%3A-unknown-load-command-0x80000034-solution-in-GoLang

Related

go run doesnt get the latest tag

I'm playing with GraphQL in Go and I was trying to get gqlgen tool using the familiar go run command.
I was expecting it to retrieve the latest available tag, instead I"m somehow getting a tag which does not seem to exist in the repo at all:
$ go run github.com/99designs/gqlgen version
v0.9.1-dev
I would expect the above to return per the latest tag
v0.13.0
Go version installed on my workstation:
$ go version
go version go1.15.5 darwin/amd64
Anyone has any ideas what's going on?
UPDATE: disabling GOPROXY does not help
UPDATE2: it turns out the version is hardcoded into version.go as you can see here, but even if go run gets the master instead of the latest tag, you'd still expect the output to be 0.13.0-dev as per the master branch Instead I suspect there is some string ordering of versions of tags which orders 0.9.* above 0.1*.*
go run does not currently support running a specific version of a binary, but note that there is an accepted Go proposal to add that functionality in a future release of the go command.
As of Go 1.16, you can instead go install the binary at a specific version, and then run that binary from its install location (either $(go env GOBIN) or $(go env GOPATH)/bin).
$ GOBIN=~/bin go install github.com/99designs/gqlgen#latest
$ ~/bin/gqlgen ...
I think the version command was misconfigured on build, and that v0.9.1-dev was not the tag at build time.

Difficulty installing go buffalo using go mod on windows

I am very new to golang. I am trying to work with the gomod. Trying to explore the go buffalo framework. But finding a bit of difficulty in installing that.
What I have done:
I saw that go get is nomore supported for buffalo and so switched to go modules.
Created a module by go mod init github.com/webbuffalotest
Fetched go get -v github.com/gobuffalo/buffalo (on the same directory where I have go.mod file)
Fetched go get -v github.com/mattn/go-sqlite3 (on the same directory where I have go.mod file)
go install github.com/gobuffalo/buffalo
I was expecting a buffalo.exe inside %GOPATH%/bin so that I can add it to my path but didn't find one.
My question is what's wrong? Is the exe not installed or it's somewhere else because of go mod. Any help will be highly appreciated.
I am using windows 10. I am not willing to install package managers as scoop or choco to install buffalo. Thanks for your patience :)
Edited:
Also tried setting set GO111MODULE=on but of no use.
Solved:
My bad, I should have used go install github.com/gobuffalo/buffalo/buffalo instead of go install github.com/gobuffalo/buffalo
github.com/gobuffalo/buffalo is a library; the corresponding binary is (aptly-named) github.com/gobuffalo/buffalo/buffalo.
The go install command you ran should have warned you about that, but didn't because go install used to also be used to cache compiled libraries (it no longer does that in module mode).
I've filed https://golang.org/issue/46912 to add a diagnostic.

cannot find package "google.golang.org/protobuf/cmd/protoc-gen-go"

The page Protocol Buffer Basics: Go says 2 things:
1) Download the package and follow instructions in README
2) Run go install google.golang.org/protobuf/cmd/protoc-gen-go
Following the Download Protocol Buffers points to the release page which has tar and zip files for lots of languages (C++, C#, ...) but not Go. The file protobuf-all-3.12.3.tar.gz has many languages, but not Go. The README says for Go, head off to Go support for Protocol Buffers which says that it has been superseded by module google.golang.org/protobuf. There aren't any installation instructions by the time I've got there, just more general stuff pointing to even more pages. So I tried step (2)
go install google.golang.org/protobuf/cmd/protoc-gen-go
and got
can't load package: package google.golang.org/protobuf/cmd/protoc-gen-go: cannot find package "google.golang.org/protobuf/cmd/protoc-gen-go" in any of ...
I have 9 tabs open on my browser pointing to various Golang Protocol Buffer pages, and I still haven't managed to get going. I've downloaded protoc and got it working ok for Java and Python, but installing Go has got me beat so far. Is there a page that tells me what to do, in a simple way? Once upon a time using the Github repository it was easy, but that was long ago...
Thanks, Jan
Running
go get -u google.golang.org/protobuf/cmd/protoc-gen-go
first before go install seems to have solved it.
Make sure you have a go.mod:
go mod init github.com/org/repo
Have you tried installing the binary with the below command:
go install github.com/golang/protobuf/protoc-gen-go
If you are looking for a specific version, try:
go install github.com/golang/protobuf/protoc-gen-go#v1.3
Note: Make sure you set the GOBIN before you run the above commands
Thanks
Download protoc binary for required OS: github.com => protobuf => releases
Add protoc to $PATH
Install protoc-gen-go to $GOBIN:
user ~ % go install github.com/golang/protobuf/protoc-gen-go
go: finding github.com/golang/protobuf/protoc-gen-go latest
go: downloading google.golang.org/protobuf v1.23.0
go: extracting google.golang.org/protobuf v1.23.0
go: finding google.golang.org/protobuf v1.23.0
Note: to specific version add #v + version
Note: Go Automatically install protoc-gen-go binary to $GOBIN, if $GOBIN did not set, it's equals $GOPATH/bin.
see this.
https://developers.google.com/protocol-buffers/docs/reference/go-generated
you need go version 1.16 or higher. check that.
As pointed out in #jeremyko's comment, you will need Go 1.16 or higher. I personally installed Go from the APT repository, which often has outdated packages. It installed 1.13, so I had problems with installing OpenSnitch.
You can download the latest version from here.

Unknown subcommand "mod" error while running go mod init

I have installed the go language in my ubuntu using sudo apt install golang-go.
It was successfully installed. When i run go version I am getting go version go1.10.4 linux/amd64
but when i tried running go mod init projectName I am getting the following error go: unknown subcommand "mod"
Do I need to install mod package or am i missing something? I have implemented the solution given by christophe in this forum but it didn't work for me.
Preliminary module support was added in Go 1.11, so Go 1.10 knows no mod subcommand.
You need to install a newer, preferably the newest 1.14 version of Go. Get it from the official downloads page. Go 1.10 is not even supported anymore (doesn't receive security patches).
The prepared packages of OSes usually lag behind new releases. I'd advise to always get Go from the official page.
Because preliminary support for go-modules came in version 1.11 and 1.12.
More here
I suggest that you install using the linux build directly from golang

Limit VS Code for Go to download packages only for v 1.11

I am using Visual Studio Code version 1.33.1 as IDE for our Go applications. We would like to use Go version 1.11 for our applications. However looks like one or more of the dependencies we are using has downloaded a package for Go 1.12. Now, VS Code is failing to build the application with the following error:
go build golang.org/x/sys/unix: module requires Go 1.12 go build
github.com/pelletier/go-toml: module requires Go 1.12
go [1,1]
I tried re-installing Go 1.11, removed the offending packages and let it reinstall. No matter when I tried to build VS Code is downloading the 1.12 version fails to build.
I would like VS Code not to download 1.12 version of the packages and restrict it to 1.11 only.
Go 1.12 Release Notes (February 2019)
Modules
The go directive in a go.mod file now indicates the version of the
language used by the files within that module. It will be set to the
current release (go 1.12) if no existing version is present. If the go
directive for a module specifies a version newer than the toolchain in
use, the go command will attempt to build the packages regardless, and
will note the mismatch only if that build fails.
This changed use of the go directive means that if you use Go 1.12 to
build a module, thus recording go 1.12 in the go.mod file, you will
get an error when attempting to build the same module with Go 1.11
through Go 1.11.3. Go 1.11.4 or later will work fine, as will releases
older than Go 1.11. If you must use Go 1.11 through 1.11.3, you can
avoid the problem by setting the language version to 1.11, using the
Go 1.12 go tool, via go mod edit -go=1.11.
$ go help go.mod
The go.mod file itself is line-oriented, with // comments but
no /* */ comments. Each line holds a single directive, made up of a
verb followed by arguments. For example:
module my/thing
go 1.12
require other/thing v1.0.2
require new/thing/v2 v2.3.4
exclude old/thing v1.2.3
replace bad/thing v1.4.5 => good/thing v1.4.5
The verbs are
module, to define the module path;
go, to set the expected language version;
require, to require a particular module at a given version or later;
exclude, to exclude a particular module version from use; and
replace, to replace a module version with a different module version.
A possible solution to your problem was first introduced in Go1.12: the go.mod verb go, to set the expected language version.
UPDATE:
Comment: I tried using the suggested command: go mod edit -go=1.11 I
got an error: flag provided but not defined: -go I manually edited to
add go 1.11 right under my module declaration in all go.mod files, it
did not work. –
user2995358
Your results are expected. As I explained before and the documentation states, the go.mod verb go was first introduced in Go1.12.
For example, the expected results,
$ go version
go version go1.11.10 linux/amd64
$ go mod edit -go=1.11
flag provided but not defined: -go
usage: go mod edit [editing flags] [go.mod]
Run 'go help mod edit' for details.
$
$ go version
go version go1.12.5 linux/amd64
$ go mod edit -go=1.11
$
Read the documentation:
$ go version
go version go1.11.10 linux/amd64
$ go1.11 help modules
Preliminary module support
Go 1.11 includes preliminary support for Go modules,
including a new module-aware 'go get' command.
We intend to keep revising this support, while preserving compatibility,
until it can be declared official (no longer preliminary),
and then at a later point we may remove support for work
in GOPATH and the old 'go get' command.
$
$ go version
go version devel +004fb5cb8d Fri May 3 03:49:11 2019 +0000 linux/amd64
$ go help modules
Module support
Go 1.13 includes official support for Go modules,
including a module-aware 'go get' command.
Module-aware mode is active by default.
$
Go 1.11 includes only preliminary support for Go modules. Go 1.13 includes full official support for Go modules.
Why do you expect everything to work flawlessly in Go1.11 with only preliminary support?

Resources