Open Student414 opened 5 years ago
Any update here? gomobile bind -mod vendor
says "flag provided but not defined: -mod". Without the flag, it always downloads packages ignoring vendor/
dir just like with a regular build.
This is on go1.14.
Hi, any update on this?
gobind -lang=go,java -outdir=/tmp/gomobile-work-1386653115 -javapkg=net.isoftservices.client ./src/game/android
unable to import bind: [-: cannot find package "." in:
/home/kordax/Projects/maxbet/octopus/vendor/golang.org/x/mobile/bind]
unable to import bind: [-: cannot find package "." in:
/home/kordax/Projects/maxbet/octopus/vendor/golang.org/x/mobile/bind]
unable to import bind: [-: cannot find package "." in:
/home/kordax/Projects/maxbet/octopus/vendor/golang.org/x/mobile/bind]
"golang.org/x/mobile/bind" is not found; run go get golang.org/x/mobile/bind: [-: cannot find package "." in:
/home/kordax/Projects/maxbet/octopus/vendor/golang.org/x/mobile/bind]
I get the same error using vendor/
/ go version go1.18.3 linux/amd64
Some further digging, starting from scratch:
From: https://pkg.go.dev/golang.org/x/mobile/cmd/gomobile
$ go install golang.org/x/mobile/cmd/gomobile@latest
$ export PATH=$PATH:/home/user/go/bin
$ gomobile init
$ gomobile version
gomobile version unknown: cannot test gomobile binary: exit status 1, no required module provides package
golang.org/x/mobile/cmd/gomobile: go.mod file not found in current directory or any parent directory;
see 'go help modules'
Ok, so in a module:
$ mkdir test ; cd test ; go mod init test.com
go: creating new go.mod: module test.com
And: git init ; echo "test" > readme.md ; git add readme.md ; git commit -m "Initial"
$ go mobile version
gomobile version unknown: cannot test gomobile binary: exit status 1, no required module provides package
golang.org/x/mobile/cmd/gomobile; to add it:
go get golang.org/x/mobile/cmd/gomobile
Run go get:
$ go get golang.org/x/mobile/cmd/gomobile
go: added golang.org/x/mobile v0.0.0-20220722155234-aaac322e2105
go: added golang.org/x/mod v0.4.2
go: added golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e
go: added golang.org/x/tools v0.1.8-0.20211022200916-316ba0b74098
go: added golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
$ go mod tidy
go: warning: "all" matched no packages
$ gomobile version
gomobile version unknown: cannot test gomobile binary: exit status 1, no required module provides package
golang.org/x/mobile/cmd/gomobile; to add it:
go get golang.org/x/mobile/cmd/gomobile
Ok, try example:
Download https://cs.opensource.google/go/x/mobile/+/aaac322e:example/basic/main.go
$ go mod tidy
go: downloading golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56
go: downloading golang.org/x/image v0.0.0-20190802002840-cff245a6509b
$ go mod vendor
$ gomobile version
gomobile version unknown: cannot test gomobile binary: exit status 1, cannot find package "." in:
/home/user/test/vendor/golang.org/x/mobile/cmd/gomobile
Ok, apparently golang.org/x/mobile/cmd/gomobile
is never added to go.mod
since not being a dependency.
Force dependency by adding package to main.go
:
_ "golang.org/x/mobile/cmd/gomobile"
Try again:
$ go mod tidy
$ go mod vendor
$ gomobile version
gomobile version unknown: binary is out of date, re-install it
Here is when the error is triggered in go mobile source: https://github.com/golang/mobile/blob/8578da9835fd365e78a6e63048c103b27a53a82c/cmd/gomobile/version.go#L46
Apparently go list -f {{.Stale}} golang.org/x/mobile/cmd/gomobile
should return false
, but it returns true
in our test module:
$ go list -f {{.Stale}} golang.org/x/mobile/cmd/gomobile
true
If we use StaleReason
:
$ go list -f {{.StaleReason}} golang.org/x/mobile/cmd/gomobile
We get:
stale dependency: golang.org/x/mobile/internal/sdkpath
On other test repo we get the same reason, just a different dependency path (e.g. stale dependency: cgo
)
My current knowledge of golang doesn't go as far as to know how to investigate this further. Hope someone else can pick this up.
go version go1.18.3 linux/amd64
Can someone from the gomobile team comment? I still cannot use gomobile with vendoring and go modules. I am using GO111MODULE=off
as a workaround, which is not great.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
import ( "time" "math/rand"
) // I want to export this function only func Start(filePath string) { crypto.DefaultSalt = "frp" rand.Seed(time.Now().UnixNano())
}
gomobile: D:\Work\go\gopath\bin\gobind.exe -lang=go,java -outdir=C:\Users\Wang\AppData\Local\Temp\gomobile-work-225577183 github.com/fatedier/frp/cmd/frpc/sub failed: exit status 1 type-checking package "github.com/fatedier/frp/cmd/frpc/sub" failed (D:\Work\go\gopath\src\github.com\fatedier\frp\cmd\frpc\sub\http.go:22:2: could not import github.com/spf13/cobra (type-checking package "github.com/spf13/cobra" failed (D:\Work\go\gopath\pkg\mod\github.com\spf13\cobra@v0.0.3\bash_completions.go:11:2: could not import github.com/spf13/pflag (cannot find package "github.com/spf13/pflag" in any of: D:\Work\go\src\github.com\spf13\pflag (from $GOROOT) D:\Work\go\gopath\src\github.com\spf13\pflag (from $GOPATH)))))