Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Go
import "os"
import "path/filepath"
path := os.Args[0]
s = filepath.Base(path)

The program path is its "0th argument".
import (
  "os"
  "path/filepath"
)
path, err := os.Executable()
if err != nil {
  panic(err)
}
s = filepath.Base(path)

Executable function is supported since 1.8
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Directories; use Ada.Directories;
S : String := (Simple_Name (Command_Name));

New implementation...
< >
programming-idioms.org