Skip to content

Instantly share code, notes, and snippets.

@gregworley
Created September 22, 2010 17:21
Show Gist options
  • Save gregworley/592107 to your computer and use it in GitHub Desktop.
Save gregworley/592107 to your computer and use it in GitHub Desktop.
package main
import (
"os"
"flag" // command line option parser
)
var omitNewline = flag.Bool("n", false, "don't print final newline")
const (
Space = " "
Newline = "\n"
)
func main() {
flag.Parse() // Scans the arg list and sets up flags
var s string = ""
for i := 0; i < flag.NArg(); i++ {
if i > 0 {
s += Space
}
s += flag.Arg(i)
}
if !*omitNewline {
s += Newline
}
os.Stdout.WriteString(s)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment