diff options
author | Rob Pike <r@golang.org> | 2009-01-09 15:16:31 -0800 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2009-01-09 15:16:31 -0800 |
commit | bc23ce679061b8f41f551578181b9feeb24f5c0a (patch) | |
tree | 64f4931996e82c6dff92d3c7647814b7c43469b3 /doc/progs/echo.go | |
parent | 0509e08028f63b53b65f294e06d603ccfdb76c22 (diff) | |
download | golang-bc23ce679061b8f41f551578181b9feeb24f5c0a.tar.gz |
update tutorial to new language.
add a section on printing
add a section on allocation
R=rsc
DELTA=500 (278 added, 15 deleted, 207 changed)
OCL=22381
CL=22456
Diffstat (limited to 'doc/progs/echo.go')
-rw-r--r-- | doc/progs/echo.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/doc/progs/echo.go b/doc/progs/echo.go index 9dc828565..71711bfc0 100644 --- a/doc/progs/echo.go +++ b/doc/progs/echo.go @@ -5,11 +5,11 @@ package main import ( - OS "os"; - Flag "flag"; + "os"; + "flag"; ) -var n_flag = Flag.Bool("n", false, nil, "don't print final newline") +var n_flag = flag.Bool("n", false, "don't print final newline") const ( Space = " "; @@ -17,16 +17,16 @@ const ( ) func main() { - Flag.Parse(); // Scans the arg list and sets up flags + flag.Parse(); // Scans the arg list and sets up flags var s string = ""; - for i := 0; i < Flag.NArg(); i++ { + for i := 0; i < flag.NArg(); i++ { if i > 0 { s += Space } - s += Flag.Arg(i) + s += flag.Arg(i) } - if !n_flag.BVal() { + if !*n_flag { s += Newline } - OS.Stdout.WriteString(s); + os.Stdout.WriteString(s); } |