-
Notifications
You must be signed in to change notification settings - Fork 18k
x/mobile: os.Executable() panics on iOS #22529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
CC @minux, the author of https://golang.org/cl/16551 . |
Related is #24394, which occurs on macOS. We should obviously gracefully handle the empty string case, but it'd be good to also get it to be non-empty when possible. :) |
I was thinking about changing the current implementation of executable() that does not check for the empty string: func executable() (string, error) {
ep := executablePath
if ep[0] != '/' {
if initCwdErr != nil {
return ep, initCwdErr
} to something like: func executable() (string, error) {
ep := executablePath
if len(ep) == 0 {
return ep, errors.New("cannot find executable path")
}
if ep[0] != '/' {
if initCwdErr != nil {
return ep, initCwdErr
} CL here |
Change https://golang.org/cl/127546 mentions this issue: |
What version of Go are you using (
go version
)?go version go1.9.2 darwin/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/adamb/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.9.2/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.9.2/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/g2/km2y9qqj4bbf329f2bt1xqc80000gn/T/go-build521592560=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
What did you do?
I have a function which calls
os.Executable
in my Go source file. I bind it with gomobile like this:gomobile bind --target ios --tags ios -v
and use the output framework in my iOS project in Xcode 9. Finally, I just call my Go function from ObjC.What did you expect to see?
An executable path or error.
What did you see instead?
A panic:
The text was updated successfully, but these errors were encountered: