Next: , Up: Exercises   [Index]


1.2.4.1 Exercise 1.1

Modify the echo program to also print os.Args[0], the name of the command that invoked it.

// Echo the name of the command that invokes this package.
package main

import (
        "fmt"
        "os"
        "strings"
 )

func main() {
          fmt.Println(strings.Join(os.Args[0:], " "))
}

Listing 1.11: Ch1 Exercise 1.1