"expected pseudo-register; found R13" error - go

I just run a go project with goland and got error as blow:
# github.com/choleraehyq/pid
../../../.go/pkg/mod/github.com/choleraehyq/pid#v0.0.10/pid_go1.5_amd64.s:28: expected pseudo-register; found R13
../../../.go/pkg/mod/github.com/choleraehyq/pid#v0.0.10/pid_go1.5_amd64.s:29: expected pseudo-register; found R14
asm: assembly of ../../../.go/pkg/mod/github.com/choleraehyq/pid#v0.0.10/pid_go1.5_amd64.s failed
I'm confused about this error and I don't know what todo. I can't do some debug work by this error message and didn't get any useful informations from google. github.com/choleraehyq/pid is referred by under framework.
I just want to know what happened and how to fix it. Please help me, thank you every much.

My go version is 1.17.6, also with this problem.
I solve the problem by updating the package version:
go get -u github.com/choleraehyq/pid
go get: upgraded github.com/choleraehyq/pid v0.0.10 => v0.0.13

It happened when I update go version from 1.13 -> 1.19
and I solve the problem by updating the package version:
go get -u github.com/choleraehyq/pid
go: downloading github.com/choleraehyq/pid v0.0.15
go: upgraded github.com/choleraehyq/pid v0.0.13 => v0.0.15

I just want to know what happened and how to fix it.
Read the instructions.
Stack Overflow: Help: How to create a Minimal, Reproducible Example
Follow the instructions.
For example,
package goid
github.com/choleraehyq/pid#v0.0.10
Programatically retrieve the current goroutine's ID.
.
$ cat pid.go
package main
import (
"fmt"
goid "github.com/choleraehyq/pid"
)
func main() {
pid := goid.GetPid()
fmt.Println(pid)
}
$
.
$ cat go.mod
module example/pid
go 1.17
require github.com/choleraehyq/pid v0.0.10
$
.
$ go version
go version go1.17.5 linux/amd64
$
.
$ go build pid.go && ./pid
# github.com/choleraehyq/pid
../../gopath/pkg/mod/github.com/choleraehyq/pid#v0.0.10/pid_go1.5_amd64.s:28: expected pseudo-register; found R13
../../gopath/pkg/mod/github.com/choleraehyq/pid#v0.0.10/pid_go1.5_amd64.s:29: expected pseudo-register; found R14
asm: assembly of ../../gopath/pkg/mod/github.com/choleraehyq/pid#v0.0.10/pid_go1.5_amd64.s failed
$
Upgrade to the latest version.
.
$ go get -u github.com/choleraehyq/pid
go: downloading github.com/choleraehyq/pid v0.0.13
go: upgraded github.com/choleraehyq/pid v0.0.10 => v0.0.13
$
.
$ cat go.mod
module example/pid
go 1.17
require github.com/choleraehyq/pid v0.0.13
$
.
$ go build pid.go && ./pid
1
$
Avoid using old, obsolete, and unsupported versions of software.
UPDATE:
Comment from OP:
Thanks. The original project is a big project and has deep dependencies. I find that I need to add github.com/choleraehyq/pid v0.0.13 // indirect to the project's go.mod. – sh1yu

It happened to me too. It maybe related to your golang's version;
I changed my golang's version from 1.17 to 1.14, which solved the problem.

Related

i am unable to install subzy tool in my linux it shows error

I tried to install this subzy tool from GitHub but it shows this kind of error and I can't install it I have faced the same problem with other programs written in (GO language).
I can clone the programs written in python but I am unable to clone the programs written in go language once I clone I don't know how to install them
****➜ ~ go install -v github.com/lukasikic/subzy#latest
go: finding a module f**or package github.com/mitchellh/go-homedir
go: finding module for package github.com/logrusorgru/aurora
go: found github.com/logrusorgru/aurora in github.com/logrusorgru/aurora v2.0.3+incompatible
go: found github.com/mitchellh/go-homedir in github.com/mitchellh/go-homedir v1.1.0
➜ ~ go get -u -v github.com/lukasikic/subzy
go get: installing executables with 'go get' in module mode is deprecated.
Use 'go install pkg#version' instead.
For more information, see https://golang.org/doc/go-get-install-deprecation
or run 'go help get' or 'go help install'.
➜ ~**
Welcome to the community,
Check the closed repo, whether it has go.mod and go.sum files
Check the version of the go (go mod is enforced in recent version meaning)
Check and learn about go mod and how to use (https://go.dev/blog/using-go-modules)

go 1.18 in google.cloud

Description
I am trying to install a library from a go v1.18 program to access Google Cloud.
Previously, the "go get" command was used, but since version 1.18, it is no longer available.
It seems to use go install, but I get an error when executing the command.
% go install cloud.google.com/go/bigquery
go: 'go install' requires a version when current directory is not in a module
Try 'go install cloud.google.com/go/bigquery#latest' to install the latest version
% go install cloud.google.com/go/bigquery#latest
package cloud.google.com/go/bigquery is not a main package
% go install cloud.google.com/go#latest
package cloud.google.com/go is not a main package
Environments
% go version
go version go1.18 darwin/amd64
% uname -v
Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64
% sw_vers
ProductName: macOS
ProductVersion: 12.3.1
BuildVersion: 21E258
Reference
bigquery package - cloud.google.com/go/bigquery - pkg.go.dev
I tried,
Thank you for your support.
% go mod init cloud.google.com/go
% go get -u cloud.google.com/go/datacatalog
go: added cloud.google.com/go/datacatalog v1.3.0
% go mod tidy
go: downloading google.golang.org/appengine v1.6.7
go: downloading golang.org/x/sys v0.0.0-20220209214540-3681064d5158
% go mod vendor
% go run catalog.go
package command-line-arguments is not a main package
What should I do next ?
Self resolved.
-> change package name "main"
go install is used to install binary programs available on the package. Usually command line tools.
go get, until go1.18, was used to update packages and install programs, they change it by split in several programs
Seems there is nothing to install. Also the main package is not bigquery but cloud.google.com/go
If you want to install a dependency, if you are using vendorized modules you can do
$ go get -u cloud.google.com/go/bigquery
$ go mod tidy
$ go mod vendor
If not, you may try it by running go mod init first

Installing a Go tool from github and facing installation errors

I want to install this tool from github : https://github.com/ethicalhackingplayground/ssrf-tool
I am using the cmd : go install github.com/ethicalhackingplayground/ssrf-tool#latest
Output :
go: finding module for package github.com/projectdiscovery/gologger
go: finding module for package github.com/briandowns/spinner
go: finding module for package github.com/logrusorgru/aurora
go: found github.com/briandowns/spinner in github.com/briandowns/spinner v1.18.1
go: found github.com/logrusorgru/aurora in github.com/logrusorgru/aurora v2.0.3+incompatible
go: found github.com/projectdiscovery/gologger in github.com/projectdiscovery/gologger v1.1.4
# github.com/ethicalhackingplayground/ssrf-tool
..\..\..\go\pkg\mod\github.com\ethicalhackingplayground\ssrf-tool#v0.0.0-20200901082948-7f3cffc3c7bb\ssrftool.go:34:2: undefined: gologger.Printf
..\..\..\go\pkg\mod\github.com\ethicalhackingplayground\ssrf-tool#v0.0.0-20200901082948-7f3cffc3c7bb\ssrftool.go:35:2: undefined: gologger.Infof
..\..\..\go\pkg\mod\github.com\ethicalhackingplayground\ssrf-tool#v0.0.0-20200901082948-7f3cffc3c7bb\ssrftool.go:36:2: undefined: gologger.Infof
I am super new to golang, go installation is fine in my system because other tools from github are working fine.
If some changes are required in the code of this tool, please suggest so.
This sources created without go module support and an old version of gologger, here is a workaround:
Clone repository git clone git#github.com:ethicalhackingplayground/ssrf-tool.git
cd ssrf-tool create go.mod file with content:
module github.com/ethicalhackingplayground/ssrf-tool
go 1.17
require (
github.com/briandowns/spinner v1.18.1
github.com/logrusorgru/aurora v2.0.3+incompatible
github.com/projectdiscovery/gologger v1.0.1
)
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.7.0 // indirect
github.com/mattn/go-colorable v0.1.2 // indirect
github.com/mattn/go-isatty v0.0.8 // indirect
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223 // indirect
)
download deps go mod download
Build executable go build .
./ssrf-tool --help
Profit.
Here is the repo with the problem fixed.
go install github.com/R0X4R/ssrf-tool#latest
or
git clone https://github.com/R0X4R/ssrf-tool.git
cd ssrf-tool
go build ssrftool.go && mv ssrftool /usr/bin/

What does it mean the code in my directory "expects" a particular import?

A Go language tutorial uses the "quote" package to get familiar quotes. When I give the command "go get -v rsc.io/quote", I get the message
code in directory.../github/hello/src/rsc.io/quote/v3 expects import "rsc.io/quote"
So I went there and looked at the code. It has an import statement:
import "rsc.io/quote/v3"
So I thought maybe I had the wrong version of quote. Accordingly, I tried "go get -v rsc.io/quite/v3" THis produces the message:
code in directory .../rsc.io/quote/v3 expects import "rsc.io/quote."
This seems circular: asking without a version number produces a requirement for a versioned package, but trying to get a versioned package produces a requirement without a version number.
If you continue the tutorial to the end you will see that the addition of a go module, and the subsequent initialisation, will resolve your issue. The .mod file will pull in the required dependencies.
Can you try
go get -v rsc.io/quote
get "rsc.io/quote": found meta tag get.metaImport{Prefix:"rsc.io/quote", VCS:"git", RepoRoot:"https://github.com/rsc/quote"} at //rsc.io/quote?go-get=1
rsc.io/quote (download)
get "rsc.io/sampler": found meta tag get.metaImport{Prefix:"rsc.io/sampler", VCS:"git", RepoRoot:"https://github.com/rsc/sampler"} at //rsc.io/sampler?go-get=1
rsc.io/sampler (download)
github/gospace/src/rsc.io/quote/quote.go:8:8: code in directory /Users/james/github/gospace/src/rsc.io/quote/v3 expects import "rsc.io/quote"
cat $GOPATH/src/rsc.io/quote/v3/go.mod
module rsc.io/quote/v3
require rsc.io/sampler v1.3.0
~> cat $GOPATH/src/rsc.io/quote/v3/go.sum
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:qgOY6WgZOaTkIIMiVjBQcw93ERBE4m30iBm00nkL0i8=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
rsc.io/sampler v1.99.99 h1:7i08f/p5TBU5joCPW3GjWG1ZFCmr28ybGqlXtelhEK8=
rsc.io/sampler v1.99.99/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
More about go get vs go install. What is the difference between go get and go install?
Can you please check your GO env path settings:
export GOPATH=$HOME/github/<your_workspace_name>
export GOBIN=$GOPATH/bin
export GOROOT=/usr/local/go
export PATH=$PATH:/usr/local/bin:/usr/local/go/bin:$GOPATH/bin
Here is a good source for setting up workspace:
https://golang.org/doc/gopath_code.html
As #MartinBennett mentioned, it's already mentioned in the tutorial but may be not so clear.
Once you add import "rsc.io/quote" in your hello.go file, you will need to run these commands in your terminal:
1-
go mod init hello
2-
go run hello.go

go mod update dependencies and leave local

I have a package that uses some local packages
module mycompany.com/clientname/server
go 1.14
require (
github.com/lib/pq v1.7.0
github.com/99designs/gqlgen v0.11.3
github.com/vektah/gqlparser/v2 v2.0.1
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
mycompany.com/clientname/models v0.0.0-00010101000000-000000000000
mycompany.com/common/utils v0.0.0-00010101000000-000000000000
)
replace mycompany.com/common/utils => ../../common/utils
replace mycompany.com/clientname/models => ../models
the mycompany.com domain doesn't serve the package, it is just a fictional path (and I use it in my gopath ~/go/src/mycompany.com/...)
the problem is that when I run go get -u all, I want the 'valid' packages to be updated (like the github.com/lib/pq or github.com/99designs/gqlgen), but to leave the local (fictional) packages as they are.
but go get -u all just prints out the new versions, then prints the errors on the local packages and then doesn't change go.mod.
go: google.golang.org/grpc upgrade => v1.30.0
go: go.opencensus.io upgrade => v0.22.4
go: github.com/mattn/go-runewidth upgrade => v0.0.9
go: github.com/gogs/chardet upgrade => v0.0.0-20191104214054-4b6791f73a28
go: golang.org/x/text upgrade => v0.3.3
go: github.com/mitchellh/mapstructure upgrade => v1.3.2
go get all: unrecognized import path "mycompany.com/clientname/models": reading https://mycompany.com/clientname/models?go-get=1: 404 Not Found
go get all: unrecognized import path "mycompany.com/common/utils": reading https://mycompany.com/common/utils?go-get=1: 404 Not Found
The error from go get -u was a bug in the go command, fixed in the upcoming Go 1.16 release. See https://golang.org/issue/32567 for detail.
(That said, ideally you should be hosting the modules in version control and using GOPRIVATE=mycompany.com instead of slotting things in locally via replace directives.)

Resources