mirror of
https://github.com/golang/go
synced 2024-11-14 15:20:43 -07:00
a38a917aee
You were a useful port and you've served your purpose. Thanks for all the play. A subsequent CL will remove amd64p32 (including assembly files and toolchain bits) and remaining bits. The amd64p32 removal will be separated into its own CL in case we want to support the Linux x32 ABI in the future and want our old amd64p32 support as a starting point. Updates #30439 Change-Id: Ia3a0c7d49804adc87bf52a4dea7e3d3007f2b1cd Reviewed-on: https://go-review.googlesource.com/c/go/+/199499 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
35 lines
868 B
Go
35 lines
868 B
Go
// Copyright 2016 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// +build linux netbsd dragonfly js,wasm
|
|
|
|
package os
|
|
|
|
import (
|
|
"errors"
|
|
"runtime"
|
|
)
|
|
|
|
// We query the executable path at init time to avoid the problem of
|
|
// readlink returns a path appended with " (deleted)" when the original
|
|
// binary gets deleted.
|
|
var executablePath, executablePathErr = func() (string, error) {
|
|
var procfn string
|
|
switch runtime.GOOS {
|
|
default:
|
|
return "", errors.New("Executable not implemented for " + runtime.GOOS)
|
|
case "linux", "android":
|
|
procfn = "/proc/self/exe"
|
|
case "netbsd":
|
|
procfn = "/proc/curproc/exe"
|
|
case "dragonfly":
|
|
procfn = "/proc/curproc/file"
|
|
}
|
|
return Readlink(procfn)
|
|
}()
|
|
|
|
func executable() (string, error) {
|
|
return executablePath, executablePathErr
|
|
}
|