shad-go/lectures/01-basics/flag/main.go

21 lines
260 B
Go
Raw Normal View History

2020-02-20 14:40:51 +00:00
package main
import (
"flag"
"fmt"
"strings"
)
var (
n = flag.Bool("n", false, "omit trailing newline")
sep = flag.String("s", " ", "separator")
)
func main() {
flag.Parse()
fmt.Print(strings.Join(flag.Args(), *sep))
if !*n {
fmt.Println()
}
}