I compile a program with Go for various platforms and run it by calling a relative path or just by its name (if it is in the PATH variable).
Is it possible to find o
Use package osext.
It's providing function Executable() that returns an absolute path to the current program executable.
It's portable between systems.
Online documentation
package main
import (
"github.com/kardianos/osext"
"fmt"
)
func main() {
filename, _ := osext.Executable()
fmt.Println(filename)
}