]> Cypherpunks repositories - gostls13.git/commitdiff
tutorial: make stdin, stdout, stderr work on Windows.
authorRob Pike <r@golang.org>
Tue, 18 Jan 2011 19:01:47 +0000 (11:01 -0800)
committerRob Pike <r@golang.org>
Tue, 18 Jan 2011 19:01:47 +0000 (11:01 -0800)
R=brainman
CC=golang-dev
https://golang.org/cl/4042042

doc/go_tutorial.html
doc/progs/file.go

index 11e9b4ad777e11f10d0e53fabab7172fbc99ced3..e3d966b874eba6d32c780f3bff6a6bcc9a0673e7 100644 (file)
@@ -538,9 +538,9 @@ We can use the factory to construct some familiar, exported variables of type <c
 <p>
 <pre> <!-- progs/file.go /var/ /^.$/ -->
 24    var (
-25        Stdin  = newFile(0, &quot;/dev/stdin&quot;)
-26        Stdout = newFile(1, &quot;/dev/stdout&quot;)
-27        Stderr = newFile(2, &quot;/dev/stderr&quot;)
+25        Stdin  = newFile(syscall.Stdin, &quot;/dev/stdin&quot;)
+26        Stdout = newFile(syscall.Stdout, &quot;/dev/stdout&quot;)
+27        Stderr = newFile(syscall.Stderr, &quot;/dev/stderr&quot;)
 28    )
 </pre>
 <p>
@@ -663,7 +663,7 @@ something from the directory of installed packages.
 (Also, ''<code>file.go</code>'' must be compiled before we can import the
 package.)
 <p>
-Now we can compile and run the program:
+Now we can compile and run the program. On Unix, this would be the result:
 <p>
 <pre>
     $ 6g file.go                       # compile file package
index d3fb5ae9e820fc8893156a03f3a7211d0acd2850..df3a3cf71c86f9f99e0d9d6d2ee1cfa7f4998102 100644 (file)
@@ -22,9 +22,9 @@ func newFile(fd int, name string) *File {
 }
 
 var (
-       Stdin  = newFile(0, "/dev/stdin")
-       Stdout = newFile(1, "/dev/stdout")
-       Stderr = newFile(2, "/dev/stderr")
+       Stdin  = newFile(syscall.Stdin, "/dev/stdin")
+       Stdout = newFile(syscall.Stdout, "/dev/stdout")
+       Stderr = newFile(syscall.Stderr, "/dev/stderr")
 )
 
 func Open(name string, mode int, perm uint32) (file *File, err os.Error) {