From: Rob Pike Date: Wed, 14 Jul 2010 20:29:12 +0000 (-0700) Subject: tutorial: show how to compile helloworld3, which depends on ./file X-Git-Tag: weekly.2010-07-14~7 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=708d7160fa84ee79924fc7cf0bc29acb03406e6f;p=gostls13.git tutorial: show how to compile helloworld3, which depends on ./file make shell prompts consistent R=rsc CC=golang-dev https://golang.org/cl/1824042 --- diff --git a/doc/go_tutorial.html b/doc/go_tutorial.html index b16f320178..4c91a54242 100644 --- a/doc/go_tutorial.html +++ b/doc/go_tutorial.html @@ -650,20 +650,22 @@ We can now use our new package: 21 }

-The ''./'' in the import of ''./file'' tells the -compiler to use the ''file'' package in the current directory -rather than something from the directory of installed packages. -

+The ''./'' in the import of ''./file'' tells the compiler +to use our own package rather than +something from the directory of installed packages. +(Also, ''file.go'' must be compiled before we can import the +package.)

-You must compile ''file.go'' before any package that imports it. -

-Finally we can run the program: +Now we can compile and run the program:

-    % helloworld3
+    $ 6g file.go                       # compile file package
+    $ 6g helloworld3.go                # compile main package
+    $ 6l -o helloworld3 helloworld3.6  # link - no need to mention "file"
+    $ helloworld3
     hello, world
     can't open file; err=No such file or directory
-    %
+    $
 

Rotting cats

@@ -827,11 +829,11 @@ even though under the covers it holds a pointer to a struct. Here it is in action:

-    % echo abcdefghijklmnopqrstuvwxyz | ./cat
+    $ echo abcdefghijklmnopqrstuvwxyz | ./cat
     abcdefghijklmnopqrstuvwxyz
-    % echo abcdefghijklmnopqrstuvwxyz | ./cat --rot13
+    $ echo abcdefghijklmnopqrstuvwxyz | ./cat --rot13
     nopqrstuvwxyzabcdefghijklm
-    %
+    $
 

Fans of dependency injection may take cheer from how easily interfaces diff --git a/doc/go_tutorial.txt b/doc/go_tutorial.txt index 6ab6094c02..bcea0db2b5 100644 --- a/doc/go_tutorial.txt +++ b/doc/go_tutorial.txt @@ -471,15 +471,21 @@ We can now use our new package: --PROG progs/helloworld3.go /package/ END -The ''"./"'' in the import of ''"./file"'' tells the compiler to use our own package rather than +The ''"./"'' in the import of ''"./file"'' tells the compiler +to use our own package rather than something from the directory of installed packages. +(Also, ''"file.go"'' must be compiled before we can import the +package.) -Finally we can run the program: +Now we can compile and run the program: - % helloworld3 + $ 6g file.go # compile file package + $ 6g helloworld3.go # compile main package + $ 6l -o helloworld3 helloworld3.6 # link - no need to mention "file" + $ helloworld3 hello, world can't open file; err=No such file or directory - % + $ Rotting cats ---- @@ -549,11 +555,11 @@ even though under the covers it holds a pointer to a "struct". Here it is in action:

-	% echo abcdefghijklmnopqrstuvwxyz | ./cat
+	$ echo abcdefghijklmnopqrstuvwxyz | ./cat
 	abcdefghijklmnopqrstuvwxyz
-	% echo abcdefghijklmnopqrstuvwxyz | ./cat --rot13
+	$ echo abcdefghijklmnopqrstuvwxyz | ./cat --rot13
 	nopqrstuvwxyzabcdefghijklm
-	%
+	$
 
Fans of dependency injection may take cheer from how easily interfaces