golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
124.06k stars 17.68k forks source link

x/mobile: gomobile bind with go1.23 no exported names in the package #69612

Open 2me2 opened 1 month ago

2me2 commented 1 month ago

Go version

go version go1.23.0.darwin-amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/Users/2me2/Library/Caches/go-build'
GOENV='/Users/2me2/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/2me2/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/2me2/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/Users/2me2/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.0.darwin-amd64'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/Users/2me2/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.0.darwin-amd64/pkg/tool/darwin_amd64'
GOVCS=''
GOVERSION='go1.23.0'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/Users/2me2/Library/Application Support/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/2me2/src/play/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/q_/16fwpggs3_z0skpfkj4_cnfm0000gn/T/go-build3768234229=/tmp/go-build -gno-record-gcc-switches -fno-common'

What did you do?

go install golang.org/x/mobile/cmd/gomobile@latest gomobile init go get golang.org/x/mobile/cmd/gomobile@latest

gomobile bind -target ios -x ./mobile

inside ./mobile is a file mobile.go that has the following:

package mobile

func Blah() int {
    return 1
}

go.mod specifically specifies go1.23.0

What did you see happen?

~/src/play  > gomobile bind -target ios -x ./mobile
GOMOBILE=/Users/2me2/go/pkg/gomobile
WORK=/var/folders/q_/16fwpggs3_z0skpfkj4_cnfm0000gn/T/gomobile-work-2833558045
rm -r -f "Mobile.xcframework"
GOOS=ios CGO_ENABLED=1 $GOPATH/bin/gobind -lang=go,objc -outdir=$WORK/ios -tags=ios 2me2test/mobile
GOOS=ios CGO_ENABLED=1 $GOPATH/bin/gobind -lang=go,objc -outdir=$WORK/iossimulator -tags=ios 2me2test/mobile
rm -r -f "$WORK"
gomobile: /Users/2me2/go/bin/gobind -lang=go,objc -outdir=/var/folders/q_/16fwpggs3_z0skpfkj4_cnfm0000gn/T/gomobile-work-2833558045/iossimulator -tags=ios 2me2test/mobile failed: exit status 1
no exported names in the package "2me2test/mobile"
no exported names in the package "2me2test/mobile"
no exported names in the package "2me2test/mobile"
no exported names in the package "2me2test/mobile"

What did you expect to see?

Expected to see everything work fine without the no exported names in the package errors. It works just fine if in go.mod I change the version to 1.22.x. Only seeing this issue in 1.23.x

gabyhelp commented 1 month ago

Related Issues and Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

2me2 commented 1 month ago

2me2 was originally a different name i just find/replaced it so you can assume where you see 2me2 it could have been "asdf" or something else. Just in case someone points out gomodule name cannot start with a number (the original didn't).

hajimehoshi commented 1 month ago

/CC @hyangah @dmitshur

Just in case someone points out gomodule name cannot start with a number (the original didn't).

This is me, and this was my misundertanding: I found a module name only with a number worked https://go.dev/play/p/FfZKGZu-nQn

dr2chase commented 1 month ago

Just because I'm curious if maybe some code wasn't expecting the ".0" (I think that's new-ish) maybe try with 1.23.1. That's a very long shot, though.

2me2 commented 1 month ago

I've tried with 1.23.1 and same issue. Removing the .0 gets an error just running go mod tidy.

It works if I do 1.22.7 for example.