<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6914906347289349334</id><updated>2024-08-29T03:07:56.412-07:00</updated><title type='text'>Bits LAB</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://bitslabs.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6914906347289349334/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://bitslabs.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Bits LAB</name><uri>http://www.blogger.com/profile/13420625091230869380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6914906347289349334.post-5167218814152436605</id><published>2018-04-24T01:50:00.001-07:00</published><updated>2018-04-24T01:50:32.256-07:00</updated><title type='text'>CloverETL Designer4.9 Quick Start</title><content type='html'>&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;270&quot; src=&quot;https://www.youtube.com/embed/DR3AuHtwUfA&quot; width=&quot;480&quot;&gt;&lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://bitslabs.blogspot.com/feeds/5167218814152436605/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bitslabs.blogspot.com/2018/04/cloveretl-designer49-quick-start.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6914906347289349334/posts/default/5167218814152436605'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6914906347289349334/posts/default/5167218814152436605'/><link rel='alternate' type='text/html' href='http://bitslabs.blogspot.com/2018/04/cloveretl-designer49-quick-start.html' title='CloverETL Designer4.9 Quick Start'/><author><name>Bits LAB</name><uri>http://www.blogger.com/profile/13420625091230869380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/DR3AuHtwUfA/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6914906347289349334.post-5046753146870313219</id><published>2012-04-14T09:43:00.001-07:00</published><updated>2012-04-22T11:13:52.753-07:00</updated><title type='text'>C programming</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;b&gt;C Program Compilation&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;A simple C program&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
For this lecture, we will learn how to write, compile, and run a very basic C program, and we&lt;/div&gt;
&lt;div&gt;
will discuss the steps that are involved in creating the executable. The following C program&lt;/div&gt;
&lt;div&gt;
prints out the text “Hello world!” to the screen:&lt;/div&gt;
&lt;div&gt;
/*&lt;/div&gt;
&lt;div&gt;
* File: hello.c&lt;/div&gt;
&lt;div&gt;
* -------------&lt;/div&gt;
&lt;div&gt;
* This simple C program prints out the text &quot;Hello world!&quot;.&lt;/div&gt;
&lt;div&gt;
*/&lt;/div&gt;
&lt;div&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;/div&gt;
&lt;div&gt;
int main(void) {&lt;/div&gt;
&lt;div&gt;
printf(&quot;Hello world!\n&quot;);&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
To compile this program, we will be using the gcc compiler in Linux, which stands for “Gnu&lt;/div&gt;
&lt;div&gt;
Compiler Collection”, and it is used as follows:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
$ gcc hello.c&lt;/div&gt;
&lt;div&gt;
This creates an executable called a.out. To run the executable, you would type&lt;/div&gt;
&lt;div&gt;
$ ./a.out&lt;/div&gt;
&lt;div&gt;
Hello world!&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
If we wanted to create an executable that is named something other than a.out, we would&lt;/div&gt;
&lt;div&gt;
use the -o option in the form&lt;/div&gt;
&lt;div&gt;
$ gcc -o hello hello.c&lt;/div&gt;
&lt;div&gt;
and we could run the hello executable with&lt;/div&gt;
&lt;div&gt;
$ ./hello&lt;/div&gt;
&lt;div&gt;
Hello world!&lt;/div&gt;
&lt;div&gt;
In what follows we will go over the details of what actually happens when you invoke the C&lt;/div&gt;
&lt;div&gt;
compiler gcc.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The C compilation model&lt;/div&gt;
&lt;div&gt;
When you invoked the gcc compiler, a series of steps were performed in order to generate&lt;/div&gt;
&lt;div&gt;
an executable from the text you entered as your C program. These steps are as follows&lt;/div&gt;
&lt;div&gt;
Source Code (hello.c)&lt;/div&gt;
&lt;div&gt;
#&lt;/div&gt;
&lt;div&gt;
Preprocessor&lt;/div&gt;
&lt;div&gt;
#&lt;/div&gt;
&lt;div&gt;
Compiler&lt;/div&gt;
&lt;div&gt;
#&lt;/div&gt;
&lt;div&gt;
Assembly Code&lt;/div&gt;
&lt;div&gt;
#&lt;/div&gt;
&lt;div&gt;
Assembler&lt;/div&gt;
&lt;div&gt;
#&lt;/div&gt;
&lt;div&gt;
Object Code (hello.o)&lt;/div&gt;
&lt;div&gt;
+&lt;/div&gt;
&lt;div&gt;
Libraries&lt;/div&gt;
&lt;div&gt;
#&lt;/div&gt;
&lt;div&gt;
Linker&lt;/div&gt;
&lt;div&gt;
#&lt;/div&gt;
&lt;div&gt;
Executable (a.out or hello)&lt;/div&gt;
&lt;div&gt;
The preprocessor&lt;/div&gt;
&lt;div&gt;
The main function of the C preprocessor is to remove comments from the source code and&lt;/div&gt;
&lt;div&gt;
interpret preprocessor directives which are given by the statements that begin with #. In our&lt;/div&gt;
&lt;div&gt;
simple hello.c code, the preprocessor would strip the source of the comments contained&lt;/div&gt;
&lt;div&gt;
within the /*...*/ and would include the file called stdio.h, which contains the standard&lt;/div&gt;
&lt;div&gt;
input/output functions that are usually called within a C program. The #include statement&lt;/div&gt;
&lt;div&gt;
can either be called with&lt;/div&gt;
&lt;div&gt;
#include&amp;lt;file.h&amp;gt;&lt;/div&gt;
&lt;div&gt;
or with&lt;/div&gt;
&lt;div&gt;
#include ‘‘file.h’’&lt;/div&gt;
&lt;div&gt;
The first method tells the preprocessor to look for the file in the standard include directories,&lt;/div&gt;
&lt;div&gt;
which for Linux are in /usr/include. The second method, which uses the quotes, tells the&lt;/div&gt;
&lt;div&gt;
preprocessor that the file to be included is in the local directory. We will go into more detail&lt;/div&gt;
&lt;div&gt;
on different preprocessor directives as we look at different facets of the C programming&lt;/div&gt;
&lt;div&gt;
language.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Compiling and Assembling&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
Once the C preprocessor has stripped the source code of the comments and expanded the&lt;/div&gt;
&lt;div&gt;
preprocessor directives given by the lines that begin with # , the compiler translates the C&lt;/div&gt;
&lt;div&gt;
code into assembly language, which is a machine level code that contains instructions that&lt;/div&gt;
&lt;div&gt;
manipulate the memory and processor directly, in a layer beneath the operating system.&lt;/div&gt;
&lt;div&gt;
Usually, you do not need to see the assembly code. But you can create the assembly code&lt;/div&gt;
&lt;div&gt;
with&lt;/div&gt;
&lt;div&gt;
$ gcc -S hello.c&lt;/div&gt;
&lt;div&gt;
This will create a file called hello.s, which looks like&lt;/div&gt;
&lt;div&gt;
.file &quot;hello.c&quot;&lt;/div&gt;
&lt;div&gt;
.section .rodata&lt;/div&gt;
&lt;div&gt;
.LC0:&lt;/div&gt;
&lt;div&gt;
.string &quot;Hello world!\n&quot;&lt;/div&gt;
&lt;div&gt;
.text&lt;/div&gt;
&lt;div&gt;
.align 2&lt;/div&gt;
&lt;div&gt;
.globl main&lt;/div&gt;
&lt;div&gt;
.type main,@function&lt;/div&gt;
&lt;div&gt;
main:&lt;/div&gt;
&lt;div&gt;
pushl %ebp&lt;/div&gt;
&lt;div&gt;
movl %esp, %ebp&lt;/div&gt;
&lt;div&gt;
subl $8, %esp&lt;/div&gt;
&lt;div&gt;
andl $-16, %esp&lt;/div&gt;
&lt;div&gt;
movl $0, %eax&lt;/div&gt;
&lt;div&gt;
subl %eax, %esp&lt;/div&gt;
&lt;div&gt;
subl $12, %esp&lt;/div&gt;
&lt;div&gt;
pushl $.LC0&lt;/div&gt;
&lt;div&gt;
call printf&lt;/div&gt;
&lt;div&gt;
addl $16, %esp&lt;/div&gt;
&lt;div&gt;
leave&lt;/div&gt;
&lt;div&gt;
ret&lt;/div&gt;
&lt;div&gt;
.Lfe1:&lt;/div&gt;
&lt;div&gt;
.size main,.Lfe1-main&lt;/div&gt;
&lt;div&gt;
.ident &quot;GCC: (GNU) 3.2 20020903 (Red Hat Linux 8.0 3.2-7)&quot;&lt;/div&gt;
&lt;div&gt;
This file contains machine-level instructions like pushl and movl, which we will not go over&lt;/div&gt;
&lt;div&gt;
in much detail. What is important to understand is that the compiler is directly responsible&lt;/div&gt;
&lt;div&gt;
for converting C syntax into this machine level code.&lt;/div&gt;
&lt;div&gt;
You do not usually see this level of compilation. Instead, you see what is known as&lt;/div&gt;
&lt;div&gt;
the object code. The compiler creates the assembly code and converts the machine-level&lt;/div&gt;
&lt;div&gt;
instructions into binary code. You can create object code from a C source with&lt;/div&gt;
&lt;div&gt;
$ gcc -c hello.c&lt;/div&gt;
&lt;div&gt;
This creates a binary file called hello.o that cannot be viewed with a text viewer.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Linking&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
The object file hello.o contains a binary version of the machine language that was created&lt;/div&gt;
&lt;div&gt;
from your source code hello.c. In order to create the executable hello or a.out, you need&lt;/div&gt;
&lt;div&gt;
to use the linker to process your main function and any possible input arguments you might&lt;/div&gt;
&lt;div&gt;
use, and link your program with other programs that contain functions that your program&lt;/div&gt;
&lt;div&gt;
uses. In this very simple example, we used the printf function. The printf function is&lt;/div&gt;
&lt;div&gt;
a standard function that is provided by the C compiler that your current object file knows&lt;/div&gt;
&lt;div&gt;
nothing about. In order to use this function, we need to use the linker in order to link our&lt;/div&gt;
&lt;div&gt;
program with the precompiled libraries provided to us by the C compiler. The linker links&lt;/div&gt;
&lt;div&gt;
other precompiled object files or libraries together and creates the executable hello. When&lt;/div&gt;
&lt;div&gt;
you type&lt;/div&gt;
&lt;div&gt;
$ gcc -o hello hello.c&lt;/div&gt;
&lt;div&gt;
the gcc compiler creates an object file and does the linking for you. However, when you use&lt;/div&gt;
&lt;div&gt;
the -c option, you create an object file called hello.o. In order to link this object file and&lt;/div&gt;
&lt;div&gt;
create the executable, you can do the linking yourself by again using the gcc compiler, but&lt;/div&gt;
&lt;div&gt;
this time you provide the object files as the command line arguments rather than the source&lt;/div&gt;
&lt;div&gt;
codes. Then you would type&lt;/div&gt;
&lt;div&gt;
$ gcc hello.o -o hello&lt;/div&gt;
&lt;div&gt;
When gcc sees object files, it invokes the linker automatically and links the necessary files&lt;/div&gt;
&lt;div&gt;
to create the hello executable.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Libraries and linking in Linux&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
The beauty of the C programming language is that C itself is a relatively simple and small&lt;/div&gt;
&lt;div&gt;
compiler. The power of C becomes obvious when you use the wealth of precompiled libraries&lt;/div&gt;
&lt;div&gt;
that have already been written that you can use in your codes. We will illustrate the use of&lt;/div&gt;
&lt;div&gt;
one of the standard C libraries in an example.&lt;/div&gt;
&lt;div&gt;
Let’s say we would like to use the math library in order to take the square root of the&lt;/div&gt;
&lt;div&gt;
number 7 in our C code. All of the standard libraries in Linux are located in the /usr/lib&lt;/div&gt;
&lt;div&gt;
directory. With every standard library, there is a header file that contains information about&lt;/div&gt;
&lt;div&gt;
how to execute each of the functions in that library. In order to determine which header&lt;/div&gt;
&lt;div&gt;
file contains the function we are looking for, we use the man 3 command at the command&lt;/div&gt;
&lt;div&gt;
prompt. Let’s say we want to know which header file contains the sqrt function and how&lt;/div&gt;
&lt;div&gt;
to use this function. To do so, we type&lt;/div&gt;
&lt;div&gt;
$ man 3 sqrt&lt;/div&gt;
&lt;div&gt;
This give us information about the function and the appropriate header file to use&lt;/div&gt;
&lt;div&gt;
NAME&lt;/div&gt;
&lt;div&gt;
sqrt - square root function&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
SYNOPSIS&lt;/div&gt;
&lt;div&gt;
#include &amp;lt;math.h&amp;gt;&lt;/div&gt;
&lt;div&gt;
double sqrt(double x);&lt;/div&gt;
&lt;div&gt;
From this we know that in order to use the sqrt function, we need to use it as sqrt(7), since&lt;/div&gt;
&lt;div&gt;
the number 7 will be type cast as a double precision number. This also tells us that details&lt;/div&gt;
&lt;div&gt;
about the sqrt function can be found in /usr/include/math.h. Our simple C program that&lt;/div&gt;
&lt;div&gt;
computes square root of 7 would then be given by (Leaving out the lengthy comments for&lt;/div&gt;
&lt;div&gt;
space-conservation, but you should never leave out comments! In this case we use shorter&lt;/div&gt;
&lt;div&gt;
comments with the //):&lt;/div&gt;
&lt;div&gt;
// Program math.c&lt;/div&gt;
&lt;div&gt;
int main(void) {&lt;/div&gt;
&lt;div&gt;
sqrt(7);&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
If we try and compile our program, we will see that we get an error:&lt;/div&gt;
&lt;div&gt;
$ gcc math.c -o math&lt;/div&gt;
&lt;div&gt;
/tmp/cciMjg1a.o: In function ‘main’:&lt;/div&gt;
&lt;div&gt;
/tmp/cciMjg1a.o(.text+0x1b): undefined reference to ‘sqrt’&lt;/div&gt;
&lt;div&gt;
collect2: ld returned 1 exit status&lt;/div&gt;
&lt;div&gt;
This is an error given to us by the linker. In this case the linker is complaining to us of an&lt;/div&gt;
&lt;div&gt;
“undefined reference to sqrt”. When you get this error, it means that you did not provide&lt;/div&gt;
&lt;div&gt;
enough information to the linker because you need to tell the linker where the sqrt function&lt;/div&gt;
&lt;div&gt;
exists. You can tell the linker where certain libraries exist that must be linked with your&lt;/div&gt;
&lt;div&gt;
program with the -l flag. In our case, the standard math library is linked with our program&lt;/div&gt;
&lt;div&gt;
using the -lm flag, as in&lt;/div&gt;
&lt;div&gt;
$ gcc math.c -lm -o math&lt;/div&gt;
&lt;div&gt;
Compilation occurs without errors because the linker was able to find the sqrt function in&lt;/div&gt;
&lt;div&gt;
the standard math library. Note that in our first simple program hello.c, we did not need&lt;/div&gt;
&lt;div&gt;
to do any linking because functions in the standard C library like printf are automatically&lt;/div&gt;
&lt;div&gt;
linked with the linker. We could, however, have use the linker implicitly with&lt;/div&gt;
&lt;div&gt;
$ gcc -o hello.c -lc -o hello&lt;/div&gt;
&lt;div&gt;
and this would have linked our program with the standard C library. But the -lc flag is&lt;/div&gt;
&lt;div&gt;
redundant here because gcc does this linking automatically.&lt;/div&gt;
&lt;div&gt;
When you need header files&lt;/div&gt;
&lt;div&gt;
Now let’s assume that in our program we would also like to use a variable that is defined in the&lt;/div&gt;
&lt;div&gt;
standard math library. Variables are defined in C programs using the #define precompiler&lt;/div&gt;
&lt;div&gt;
directive. We will get into this in more detail later, but for now let’s say we need to use the&lt;/div&gt;
&lt;div&gt;
M_PI variable that is defined in the math library, which is in /usr/include/math.h. We&lt;/div&gt;
&lt;div&gt;
can find the line with the grep command with&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
$ grep M_PI /usr/include/math.h&lt;/div&gt;
&lt;div&gt;
# define M_PI 3.14159265358979323846 /* pi */&lt;/div&gt;
&lt;div&gt;
which shows us that it is defined in /usr/include/math.h as the value of   to 20 decimal&lt;/div&gt;
&lt;div&gt;
places. If we tried to use the value of M_PI in our simple C program, as in&lt;/div&gt;
&lt;div&gt;
// Program math.c&lt;/div&gt;
&lt;div&gt;
int main(void) {&lt;/div&gt;
&lt;div&gt;
sqrt(7*M_PI);&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
we get the following compiler error:&lt;/div&gt;
&lt;div&gt;
$ gcc -c math.c&lt;/div&gt;
&lt;div&gt;
math.c: In function ‘main’:&lt;/div&gt;
&lt;div&gt;
math.c:2: ‘M_PI’ undeclared (first use in this function)&lt;/div&gt;
&lt;div&gt;
It is important to understand that this error is produced by the compiler and not by the&lt;/div&gt;
&lt;div&gt;
linker. The compiler is attempting to create the object file math.o but can’t in this case&lt;/div&gt;
&lt;div&gt;
because there is no definition of the variable M_PI. In order for the compiler to know what&lt;/div&gt;
&lt;div&gt;
the value of M_PI is, we need to include the header file math.h. If we do so, and our code&lt;/div&gt;
&lt;div&gt;
looks like&lt;/div&gt;
&lt;div&gt;
// Program math.c&lt;/div&gt;
&lt;div&gt;
#include &amp;lt;math.h&amp;gt;&lt;/div&gt;
&lt;div&gt;
int main(void) {&lt;/div&gt;
&lt;div&gt;
sqrt(7*M_PI);&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
then we will get no errors when we try to create the object file with&lt;/div&gt;
&lt;div&gt;
$ gcc -c math.c&lt;/div&gt;
&lt;div&gt;
But remember, even by including the header file we still need to tell the linker about the&lt;/div&gt;
&lt;div&gt;
library that contains the sqrt function if we want to create an executable.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-large;&quot;&gt;The basics of C programming&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Basic structure of a C program&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
As we saw in the hello.c example in the last lecture, Every C program must contain a main&lt;/div&gt;
&lt;div&gt;
function , since the main function is the first function called when you run your program at&lt;/div&gt;
&lt;div&gt;
the command line. In its simplest form, a C program is given by&lt;/div&gt;
&lt;div&gt;
int main(void) {&lt;/div&gt;
&lt;div&gt;
printf(‘‘Hello world!\n’’);&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
The int stands for the “return type”, which says that the main function returns an integer&lt;/div&gt;
&lt;div&gt;
if you tell it to do so. We will get into more detail with functions and return types, but you&lt;/div&gt;
&lt;div&gt;
can return a number to the command line with the return function in C, as in&lt;/div&gt;
&lt;div&gt;
int main(void) {&lt;/div&gt;
&lt;div&gt;
printf(‘‘Hello world!\n’’);&lt;/div&gt;
&lt;div&gt;
return 2;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
When you compile and run your program, it will return a 2 to the command line, that&lt;/div&gt;
&lt;div&gt;
you can access with the $? character, which stores the value returned by the last command&lt;/div&gt;
&lt;div&gt;
executed, as in&lt;/div&gt;
&lt;div&gt;
$ ./a.out&lt;/div&gt;
&lt;div&gt;
Hello world!&lt;/div&gt;
&lt;div&gt;
$ echo $?&lt;/div&gt;
&lt;div&gt;
2&lt;/div&gt;
&lt;div&gt;
Just as in shell scripts, you can specify exit codes in C as well, which perform the same&lt;/div&gt;
&lt;div&gt;
function as the return function in the previous example:&lt;/div&gt;
&lt;div&gt;
int main(void) {&lt;/div&gt;
&lt;div&gt;
printf(‘‘Hello world!\n’’);&lt;/div&gt;
&lt;div&gt;
exit(2);&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
Compiling and running this example yields the same result as the previous example. The&lt;/div&gt;
&lt;div&gt;
void statement in main(void) tells the main function that there are no arguments being&lt;/div&gt;
&lt;div&gt;
supplied to it at the command line. We will get into this in more detail when we look at&lt;/div&gt;
&lt;div&gt;
functions.&lt;/div&gt;
&lt;div&gt;
Note that all statements in C programs end with the semicolon ; except for the preprocessor&lt;/div&gt;
&lt;div&gt;
directives that begin with #.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Variables&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Standard variable types&lt;/div&gt;
&lt;div&gt;
All variables in C must be defined before they are used. Variables in C are defined by their&lt;/div&gt;
&lt;div&gt;
type, which determines how much space they use in memory. The more memory a variable&lt;/div&gt;
&lt;div&gt;
requires, the larger the number it can store, and therefore the more precision you can obtain.&lt;/div&gt;
&lt;div&gt;
For example, to define an integer i , a floating point number x , and a character c in our&lt;/div&gt;
&lt;div&gt;
simple example, we would use&lt;/div&gt;
&lt;div&gt;
int main(void) {&lt;/div&gt;
&lt;div&gt;
int i;&lt;/div&gt;
&lt;div&gt;
float x;&lt;/div&gt;
&lt;div&gt;
char c;&lt;/div&gt;
&lt;div&gt;
printf(‘‘Hello world!\n’’);&lt;/div&gt;
&lt;div&gt;
exit(2);&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
The int type stores 4-byte integers. Since 1 byte contains 8 bits, then each integer type can&lt;/div&gt;
&lt;div&gt;
store 32 bits of information. If the first bit stores the sign, then the last 31 can store a binary&lt;/div&gt;
&lt;div&gt;
number. The largest binary number that 31 bits can store is 231 − 1. We can store a larger&lt;/div&gt;
&lt;div&gt;
(absolute value) negative number because we can assume that if the first bit is negative and&lt;/div&gt;
&lt;div&gt;
the rest are 0 then this represents the number -1, and not 0, which is represented by the&lt;/div&gt;
&lt;div&gt;
first bit being positive and the rest being 0. In C, we can specify the unsigned type, which&lt;/div&gt;
&lt;div&gt;
doubles the size of the number because we do not need to store a bit for the sign of the&lt;/div&gt;
&lt;div&gt;
number. We can also specify the short type, which is just a smaller version of the type int.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The following table lists the available types in Unix and their ranges [1]&lt;/div&gt;
&lt;div&gt;
Type Space (bytes) Range (min,max)&lt;/div&gt;
&lt;div&gt;
char 1 -,-&lt;/div&gt;
&lt;div&gt;
unsigned char 1 0,28 − 1&lt;/div&gt;
&lt;div&gt;
short int 2 −215,215 − 1&lt;/div&gt;
&lt;div&gt;
unsigned short int 2 0,216 − 1&lt;/div&gt;
&lt;div&gt;
int 4 −231, 231 − 1&lt;/div&gt;
&lt;div&gt;
float 4 ±3.2 × 10±38&lt;/div&gt;
&lt;div&gt;
double 8 ±1.7 × 10±308&lt;/div&gt;
&lt;div&gt;
You can define variables sequentially in a list or separately, line by line, as in&lt;/div&gt;
&lt;div&gt;
int i, j, k;&lt;/div&gt;
&lt;div&gt;
float x, y, z;&lt;/div&gt;
&lt;div&gt;
You can initialize variables with variables at the same time you declare them, such as&lt;/div&gt;
&lt;div&gt;
int i=0,j=1,k=1000;&lt;/div&gt;
&lt;div&gt;
float x=0,y=2,z=3;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Global variables&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
Global variables are defined at the top of your C codes before the main statement. They are&lt;/div&gt;
&lt;div&gt;
recognized everywhere in the code and not only in the function in which they are defined.&lt;/div&gt;
&lt;div&gt;
The following C code defines the variables globx and globy as global variables before the&lt;/div&gt;
&lt;div&gt;
main statement:&lt;/div&gt;
&lt;div&gt;
float globx, globy;&lt;/div&gt;
&lt;div&gt;
int main(void) {&lt;/div&gt;
&lt;div&gt;
...&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
It is normally not good practice to declare global variables in C programs. An alternative&lt;/div&gt;
&lt;div&gt;
method is to employ the preprocessor directives to define variables that you will need&lt;/div&gt;
&lt;div&gt;
throughout your programs. For example, to define the above variables as global variables,&lt;/div&gt;
&lt;div&gt;
you should define them using the preprocessor directives with&lt;/div&gt;
&lt;div&gt;
#define GLOBX 10&lt;/div&gt;
&lt;div&gt;
#define GLOBY 20&lt;/div&gt;
&lt;div&gt;
int main(void) {&lt;/div&gt;
&lt;div&gt;
...&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
Note the standard practice of defining these global variables in caps. Remember, the two&lt;/div&gt;
&lt;div&gt;
methods are very different. The first method defines and stores the variables in memory&lt;/div&gt;
&lt;div&gt;
and they can be changed in your program. The second method uses the C preprocessor to&lt;/div&gt;
&lt;div&gt;
replace all instances of GLOBX with 10 and GLOBY with 20 before any compilation takes place.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Defining your own types&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
C allows you to define your own types, and this can make your codes much more legible.&lt;/div&gt;
&lt;div&gt;
For example, you can define a type called price that you can use to define variables that&lt;/div&gt;
&lt;div&gt;
you use to represent the price of certain objects. To do so, you would use&lt;/div&gt;
&lt;div&gt;
typedef float price;&lt;/div&gt;
&lt;div&gt;
int main(void) {&lt;/div&gt;
&lt;div&gt;
price x, y;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
The typedef is used in the following way:&lt;/div&gt;
&lt;div&gt;
typedef existing_type new_type;&lt;/div&gt;
&lt;div&gt;
The price type example is identical to using&lt;/div&gt;
&lt;div&gt;
float x, y;&lt;/div&gt;
&lt;div&gt;
but it is useful to use typedef when you would like the ability to change the types of certain&lt;/div&gt;
&lt;div&gt;
variables throughout your codes by only changing one line. That is, if you wanted to change&lt;/div&gt;
&lt;div&gt;
all of your prices to type double, then you would only need to change the typedef line to&lt;/div&gt;
&lt;div&gt;
typedef double price;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Constant types&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
You can declare types that you do not want to be altered in your programs with the const&lt;/div&gt;
&lt;div&gt;
declaration. For example,&lt;/div&gt;
&lt;div&gt;
const int constant_integer=2;&lt;/div&gt;
&lt;div&gt;
declares the value of constant_integer to be 2 and this value cannot be changed in any&lt;/div&gt;
&lt;div&gt;
part of the code. It is effectively “read-only” and any attempts to change it will result in a&lt;/div&gt;
&lt;div&gt;
compiler warning such as&lt;/div&gt;
&lt;div&gt;
warning: assignment of read-only variable ‘constant_integer’&lt;/div&gt;
&lt;div&gt;
The value can ultimately be changed but the const declaration causes the compiler warning&lt;/div&gt;
&lt;div&gt;
when you do change it. You use the const declaration mostly to let users of your functions&lt;/div&gt;
&lt;div&gt;
know that the variables will not be altered.&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Formatted output&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
To print output to the screen, you use the printf statement. To print out a string to the&lt;/div&gt;
&lt;div&gt;
screen, you would use&lt;/div&gt;
&lt;div&gt;
printf(‘‘This is a string.\n’’);&lt;/div&gt;
&lt;div&gt;
Any time the \ character is encountered, it is evaluated by printf as a formatting character.&lt;/div&gt;
&lt;div&gt;
In this case, the \n character prints a carriage return to the screen. Another commonly used&lt;/div&gt;
&lt;div&gt;
formatting character is the \t character, which prints a tab to the screen, as in&lt;/div&gt;
&lt;div&gt;
printf(‘‘This string is separated\tfrom this one by a tab.\n’’);&lt;/div&gt;
&lt;div&gt;
Note that use of the \ evaluates the first character after it to determine the format, and the&lt;/div&gt;
&lt;div&gt;
next character is printed, so you do not need a space after the \t in this example. To print&lt;/div&gt;
&lt;div&gt;
the actual \ character, you would use two backslashes, as in&lt;/div&gt;
&lt;div&gt;
printf(‘‘This is a backslash: \\\n’’);&lt;/div&gt;
&lt;div&gt;
To print out the values of variables, you use the % character. As an example,&lt;/div&gt;
&lt;div&gt;
float x=5.2543;&lt;/div&gt;
&lt;div&gt;
printf(‘‘The value is %f\n’’,x);&lt;/div&gt;
&lt;div&gt;
will print out The value is 5.254300. The default of %f is to print out floating point&lt;/div&gt;
&lt;div&gt;
numbers with six digits. You can specify how many digits you would like to print with&lt;/div&gt;
&lt;div&gt;
printf(‘‘The value is %.2f\n’’,x);&lt;/div&gt;
&lt;div&gt;
which will print out two digits with The value is 5.25. If you print out several numbers,&lt;/div&gt;
&lt;div&gt;
then if they have a different number of digits before the decimal point, then the numbers&lt;/div&gt;
&lt;div&gt;
may be misaligned, as in&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
double x=5.2543, y=6558.2391;&lt;/div&gt;
&lt;div&gt;
printf(&quot;The value of x is %.2f\n&quot;,x);&lt;/div&gt;
&lt;div&gt;
printf(&quot;The value of y is %.2f\n&quot;,y);&lt;/div&gt;
&lt;div&gt;
which will print out&lt;/div&gt;
&lt;div&gt;
The value of x is 5.25&lt;/div&gt;
&lt;div&gt;
The value of y is 6558.24&lt;/div&gt;
&lt;div&gt;
You can align the numbers by specifying how many digits to print in the format, which&lt;/div&gt;
&lt;div&gt;
includes the decimal point and the digits after it. Since the number 6558.24 has 7 digits,&lt;/div&gt;
&lt;div&gt;
we can format the printout so that it prints at least 7 digits, as in&lt;/div&gt;
&lt;div&gt;
double x=5.2543, y=6558.2391;&lt;/div&gt;
&lt;div&gt;
printf(&quot;The value of x is %7.2f\n&quot;,x);&lt;/div&gt;
&lt;div&gt;
printf(&quot;The value of y is %7.2f\n&quot;,y);&lt;/div&gt;
&lt;div&gt;
which will align the decimals when the numbers are printed, as in&lt;/div&gt;
&lt;div&gt;
The value of x is 5.25&lt;/div&gt;
&lt;div&gt;
The value of y is 6558.24&lt;/div&gt;
&lt;div&gt;
Note that the format statement will always print out all of the digits before the decimal&lt;/div&gt;
&lt;div&gt;
point as well as the number you specify after it. So if you specify %4.2f to print out y in the&lt;/div&gt;
&lt;div&gt;
above example, you will still get 6558.24. This is because the number of digits you specify&lt;/div&gt;
&lt;div&gt;
is just a minimum. Other formatting statements include %d, which is used to print decimal&lt;/div&gt;
&lt;div&gt;
integers , such as&lt;/div&gt;
&lt;div&gt;
int i=5, j=6558;&lt;/div&gt;
&lt;div&gt;
printf(&quot;The value of i is %4d\n&quot;,i);&lt;/div&gt;
&lt;div&gt;
printf(&quot;The value of j is %4d\n&quot;,j);&lt;/div&gt;
&lt;div&gt;
which will print out&lt;/div&gt;
&lt;div&gt;
The value of i is 5&lt;/div&gt;
&lt;div&gt;
The value of j is 6558&lt;/div&gt;
&lt;div&gt;
You can also print characters with %c , strings with %s, octal numbers with %o, and hexadecimal&lt;/div&gt;
&lt;div&gt;
numbers with %x.&lt;/div&gt;
&lt;div&gt;
Formatted input&lt;/div&gt;
&lt;div&gt;
Formatted input is performed with the scanf function. For example, to read two floating&lt;/div&gt;
&lt;div&gt;
point numbers from the command line, you would use&lt;/div&gt;
&lt;div&gt;
scanf(‘‘%f %f’’,&amp;amp;x,&amp;amp;y);&lt;/div&gt;
&lt;div&gt;
This would convert input of the form 1 2 appropriately, even though this input is not&lt;/div&gt;
&lt;div&gt;
necessarily floating point input. To read in two integers, you would use&lt;/div&gt;
&lt;div&gt;
scanf(‘‘%d %d’’,&amp;amp;i,&amp;amp;j);&lt;/div&gt;
&lt;div&gt;
This would work fine with input that does not have decimal points, but if you try to read in&lt;/div&gt;
&lt;div&gt;
floating point numbers as integers, you will not achieve the desired result. The &amp;amp; sign stands&lt;/div&gt;
&lt;div&gt;
for the address of the variables. We will go over this when we discuss pointers.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;File I/O&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
Input and output to and from files is identical to that at the command line, except the&lt;/div&gt;
&lt;div&gt;
fprintf and fscanf functions are used and they require another argument. This additional&lt;/div&gt;
&lt;div&gt;
argument is called a file pointer. In order to write two floating point numbers to a file, you&lt;/div&gt;
&lt;div&gt;
first need to declar the file pointer with the FILE type, and you need to open it, as in&lt;/div&gt;
&lt;div&gt;
float x=1, y=2;&lt;/div&gt;
&lt;div&gt;
FILE *file;&lt;/div&gt;
&lt;div&gt;
file = fopen(‘‘file.txt’’,’’w’’);&lt;/div&gt;
&lt;div&gt;
fprintf(file,’’%f %f\n’’,x,y);&lt;/div&gt;
&lt;div&gt;
fclose(file);&lt;/div&gt;
&lt;div&gt;
The function fprintf is identical to the printf function, except now we see it has another&lt;/div&gt;
&lt;div&gt;
argument file, which is a pointer to the file. Before you use the file variable, you need to&lt;/div&gt;
&lt;div&gt;
open the file with&lt;/div&gt;
&lt;div&gt;
file = fopen(‘‘file.txt’’,’’w’’);&lt;/div&gt;
&lt;div&gt;
This opens up the file ‘‘file.txt’’ and the ‘‘w’’ which is the mode and indicates how&lt;/div&gt;
&lt;div&gt;
the file will be used. The following three modes are allowed:&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Mode String&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
Open for reading “r”&lt;/div&gt;
&lt;div&gt;
Open for writing “w”&lt;/div&gt;
&lt;div&gt;
Open and append “a”&lt;/div&gt;
&lt;div&gt;
When you are done with the file, you close it with&lt;/div&gt;
&lt;div&gt;
fclose(file);&lt;/div&gt;
&lt;div&gt;
The ‘‘r’’ mode is used when you would like to open a file for reading. To read two floating&lt;/div&gt;
&lt;div&gt;
point numbers from a file, you would use the fscanf function, which is identical to scanf,&lt;/div&gt;
&lt;div&gt;
except that it takes the file pointer as its first argument, as in&lt;/div&gt;
&lt;div&gt;
float x, y;&lt;/div&gt;
&lt;div&gt;
FILE *file;&lt;/div&gt;
&lt;div&gt;
file = fopen(‘‘file.txt’’,’’r’’);&lt;/div&gt;
&lt;div&gt;
fscanf(file,’’%f %f\n’’,&amp;amp;x,&amp;amp;y);&lt;/div&gt;
&lt;div&gt;
fclose(file);&lt;/div&gt;
&lt;div&gt;
You can check to make sure your files are opened correctly (that is, that they exist), by&lt;/div&gt;
&lt;div&gt;
checking to make sure file is not the predefined NULL pointer. We’ll discuss this pointer in&lt;/div&gt;
&lt;div&gt;
more detail later, but for now, to ensure that your file was opened correctly, you use&lt;/div&gt;
&lt;div&gt;
if(!file) printf(‘‘File did not open correctly!\n’’);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Note that in order to use the FILE type, we need to include the standard C header file with&lt;/div&gt;
&lt;div&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;/div&gt;
&lt;div&gt;
The fscanf and fprintf functions can be used to print to and read from the terminal&lt;/div&gt;
&lt;div&gt;
using the stdin, stdout,and stderr file pointers defined in stdio.h. To write to the&lt;/div&gt;
&lt;div&gt;
standard output of the terminal using fprintf, then, you would use&lt;/div&gt;
&lt;div&gt;
fprintf(stdout,’’%f %f\n’’,x,y);&lt;/div&gt;
&lt;div&gt;
which is identical to using&lt;/div&gt;
&lt;div&gt;
printf(’’%f %f\n’’,x,y);&lt;/div&gt;
&lt;div&gt;
To write to the standard error, you would use&lt;/div&gt;
&lt;div&gt;
fprintf(stderr,’’%f %f\n’’,x,y);&lt;/div&gt;
&lt;div&gt;
To read from the terminal’s standard input with fscanf, you would use&lt;/div&gt;
&lt;div&gt;
fscanf(stdin,’’%f %f’’,&amp;amp;x,&amp;amp;y);&lt;/div&gt;
&lt;div&gt;
which is identical to using&lt;/div&gt;
&lt;div&gt;
scanf(’’%f %f’’,&amp;amp;x,&amp;amp;y);&lt;/div&gt;
&lt;div&gt;
Again, in order for the compiler to know what stdin, stdout, and stderr are, you need to&lt;/div&gt;
&lt;div&gt;
include stdio.h.&lt;/div&gt;
&lt;div&gt;
Operators&lt;/div&gt;
&lt;div&gt;
Arithmetic Operators&lt;/div&gt;
&lt;div&gt;
The arithmetic operators are&lt;/div&gt;
&lt;div&gt;
*,/,%,+,-&lt;/div&gt;
&lt;div&gt;
The modulus operator % , when used as&lt;/div&gt;
&lt;div&gt;
z = x % y;&lt;/div&gt;
&lt;div&gt;
assigns z with the value of the remainder when x is divided by y. The modulus operator does&lt;/div&gt;
&lt;div&gt;
not work with types other than int, as it will truncate the result. The + and - operators have&lt;/div&gt;
&lt;div&gt;
the same precedence, which is lower than that of *, /, and %, and all arithmetic operators of&lt;/div&gt;
&lt;div&gt;
equal precedence are evaluated from left to right. Therefore, the expression&lt;/div&gt;
&lt;div&gt;
2*z-x+y*z%2&lt;/div&gt;
&lt;div&gt;
is evaluated as&lt;/div&gt;
&lt;div&gt;
((2*z)-x)+((y*z)%2)&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Relational operators&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
The relational operators are given by&lt;/div&gt;
&lt;div&gt;
&amp;lt; &amp;gt; &amp;lt;= &amp;gt;=&lt;/div&gt;
&lt;div&gt;
and the equality operators are&lt;/div&gt;
&lt;div&gt;
== !=&lt;/div&gt;
&lt;div&gt;
The relational operators exceed the equality operators in precedence, and the arithmetic&lt;/div&gt;
&lt;div&gt;
operators exceed the relational operators.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Logical operators&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
The logical operators are &amp;amp;&amp;amp; and ||, which are not to be confused with the bitwise operators&lt;/div&gt;
&lt;div&gt;
&amp;amp; and |. Logical operators are evaluated from left to right, until the evaluation is known to&lt;/div&gt;
&lt;div&gt;
be either true or false, while the precedence of the &amp;amp;&amp;amp; operator is greater than that of the ||&lt;/div&gt;
&lt;div&gt;
operator. That is,&lt;/div&gt;
&lt;div&gt;
a==b &amp;amp;&amp;amp; c==d || x==y &amp;amp;&amp;amp; w==z&lt;/div&gt;
&lt;div&gt;
is evaluated as&lt;/div&gt;
&lt;div&gt;
(a==b &amp;amp;&amp;amp; c==d) || (x==y &amp;amp;&amp;amp; w==z)&lt;/div&gt;
&lt;div&gt;
As another example, the logical relation&lt;/div&gt;
&lt;div&gt;
4==2*2 &amp;amp;&amp;amp; 3==5-1 &amp;amp;&amp;amp; 2==1&lt;/div&gt;
&lt;div&gt;
will return false as soon as the 3==5-1 is encountered, since this means the entire statement&lt;/div&gt;
&lt;div&gt;
is false, without having to evaluate the last false conditional 2==1.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Increment, decrement, and assignment operators&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
In C, the increment and decrement operators are ++ and --, so that in order to increment a&lt;/div&gt;
&lt;div&gt;
variable i and decrement it you would use i++ or i--. These operators are provided merely&lt;/div&gt;
&lt;div&gt;
for source code compactness, since they are identical to i=i+1 and i=i-1. A peculiar aspect&lt;/div&gt;
&lt;div&gt;
to the increment or decrement operators is that they can be used as prefix operators (++i)&lt;/div&gt;
&lt;div&gt;
as well as postfix operators (i++). The difference between the two is that i++ returns the&lt;/div&gt;
&lt;div&gt;
value of i before it is incremented, while ++i increments i and then returns it. For example,&lt;/div&gt;
&lt;div&gt;
in the following example,&lt;/div&gt;
&lt;div&gt;
i=2&lt;/div&gt;
&lt;div&gt;
j=i++&lt;/div&gt;
&lt;div&gt;
the value of j will be 2 while the value of i will be 3. If we use the prefix operator, as in&lt;/div&gt;
&lt;div&gt;
i=2&lt;/div&gt;
&lt;div&gt;
j=++i&lt;/div&gt;
&lt;div&gt;
Handout 7 13/03/03 9&lt;/div&gt;
&lt;div&gt;
the value of j will be 3 while the value of i will also be 3.&lt;/div&gt;
&lt;div&gt;
Assignment operators provide compact notation to assign an expression using a binary&lt;/div&gt;
&lt;div&gt;
operator to a left-hand side argument. For example, i=i+2 can be expressed using an&lt;/div&gt;
&lt;div&gt;
assignment operator as i+=2. This works with the following operators&lt;/div&gt;
&lt;div&gt;
+ - * / &amp;amp; &amp;lt;&amp;lt; &amp;gt;&amp;gt; &amp;amp; ^ |&lt;/div&gt;
&lt;div&gt;
As another examples,&lt;/div&gt;
&lt;div&gt;
x = x*(2+z)&lt;/div&gt;
&lt;div&gt;
can be expressed more compactly as&lt;/div&gt;
&lt;div&gt;
x*=2+z&lt;/div&gt;
&lt;div&gt;
Note that the argument on the right hand side of the assignment operator always takes&lt;/div&gt;
&lt;div&gt;
precendence, in that x*=2+z is not the same as x=x*2+z but is given above by x=x*(2+z).&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Precedence and order of operations&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
So far we have seen that certain operators take precendence over others and that determined&lt;/div&gt;
&lt;div&gt;
the order of operations in which the operators were performed. It is important to understand&lt;/div&gt;
&lt;div&gt;
that in C, every operator performs an operation on its arguments and then returns a result,&lt;/div&gt;
&lt;div&gt;
and the calculation proceeds from there. If you think about things this way it makes it easier&lt;/div&gt;
&lt;div&gt;
to understand the result from an operation which contains confusing precedence issues. For&lt;/div&gt;
&lt;div&gt;
example, in the statement i=i+1, the only way we know what the result will be is by knowing&lt;/div&gt;
&lt;div&gt;
that the + operator takes precendence over the = operator. So we write the above statement&lt;/div&gt;
&lt;div&gt;
as i=(i+1). We know that it is not (i=i)+1 only because the + operator takes precendence&lt;/div&gt;
&lt;div&gt;
over the = operator.&lt;/div&gt;
&lt;div&gt;
Another important aspect of operators is their associativity. That is, are the operations&lt;/div&gt;
&lt;div&gt;
evaluated from right to left or from left to right? Associativity determines how things are&lt;/div&gt;
&lt;div&gt;
evaluated by the way you would place parentheses around the operators. For example, since&lt;/div&gt;
&lt;div&gt;
+ is performed from left to right, we would evaluate a sum of several operands as&lt;/div&gt;
&lt;div&gt;
i+j+k+l+m=((((i+j)+k)+l)+m)&lt;/div&gt;
&lt;div&gt;
This may seem obvious only because of the associative property of addition, in that addition&lt;/div&gt;
&lt;div&gt;
is identical if it is evaluated from left to right or from right to left, since&lt;/div&gt;
&lt;div&gt;
((((i+j)+k)+l)+m)=(i+(j+(k+(l+m)))).&lt;/div&gt;
&lt;div&gt;
However, this does not hold true for division, since&lt;/div&gt;
&lt;div&gt;
((((i/j)/k)/l)/m)6= (i/(j/(k/(l/m)))).&lt;/div&gt;
&lt;div&gt;
We know that C performs the divisions as they are on the left because associativity of division&lt;/div&gt;
&lt;div&gt;
is from left to right. The following table shows the associativity of the operators in order of&lt;/div&gt;
&lt;div&gt;
precedence, for which the operators at the top have the highest precedence [2].&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Operator Associativity&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
() [] -&amp;gt; . left to right&lt;/div&gt;
&lt;div&gt;
! ~ ++ -- + - * &amp;amp; (type) sizeof right to left&lt;/div&gt;
&lt;div&gt;
* / % left to right&lt;/div&gt;
&lt;div&gt;
+ - left to right&lt;/div&gt;
&lt;div&gt;
&amp;lt;&amp;lt; &amp;gt;&amp;gt; left to right&lt;/div&gt;
&lt;div&gt;
&amp;lt; &amp;lt;= &amp;gt; &amp;gt;= left to right&lt;/div&gt;
&lt;div&gt;
== != left to right&lt;/div&gt;
&lt;div&gt;
&amp;amp; left to right&lt;/div&gt;
&lt;div&gt;
^ left to right&lt;/div&gt;
&lt;div&gt;
| left to right&lt;/div&gt;
&lt;div&gt;
&amp;amp;&amp;amp; left to right&lt;/div&gt;
&lt;div&gt;
|| left to right&lt;/div&gt;
&lt;div&gt;
?: right to left&lt;/div&gt;
&lt;div&gt;
= += -= *= /= %= &amp;amp;= ^= |= &amp;lt;&amp;lt;= &amp;gt;&amp;gt;= right to left&lt;/div&gt;
&lt;div&gt;
, left to right&lt;/div&gt;
&lt;div&gt;
We will deal with the -&amp;gt; and . operators when we discuss structs and pointers.&lt;/div&gt;
&lt;div&gt;
Conditionals&lt;/div&gt;
&lt;div&gt;
If and ?&lt;/div&gt;
&lt;div&gt;
The syntax of the if statement in C is given by&lt;/div&gt;
&lt;div&gt;
if ( expression )&lt;/div&gt;
&lt;div&gt;
statement&lt;/div&gt;
&lt;div&gt;
else&lt;/div&gt;
&lt;div&gt;
statement&lt;/div&gt;
&lt;div&gt;
and for multiple if statements, the syntax is given by&lt;/div&gt;
&lt;div&gt;
if ( expression )&lt;/div&gt;
&lt;div&gt;
statement&lt;/div&gt;
&lt;div&gt;
else if ( expression )&lt;/div&gt;
&lt;div&gt;
statement&lt;/div&gt;
&lt;div&gt;
else if ( expression )&lt;/div&gt;
&lt;div&gt;
statement&lt;/div&gt;
&lt;div&gt;
else&lt;/div&gt;
&lt;div&gt;
statement&lt;/div&gt;
&lt;div&gt;
where you don’t necessarily need the last default else statement . As an example, we might&lt;/div&gt;
&lt;div&gt;
use the if statement as&lt;/div&gt;
&lt;div&gt;
if ( U == 0 )&lt;/div&gt;
&lt;div&gt;
x = y;&lt;/div&gt;
&lt;div&gt;
else&lt;/div&gt;
&lt;div&gt;
x = z;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The if statement first evaluates the expression. The expression, like all expressions in C,&lt;/div&gt;
&lt;div&gt;
returns a value, which is either true (1) or false (0). Therefore, the expression U == 0 returns&lt;/div&gt;
&lt;div&gt;
a 0 when U is 0. Rather than evaluating this expression, we can more compactly use&lt;/div&gt;
&lt;div&gt;
if ( U )&lt;/div&gt;
&lt;div&gt;
x = y;&lt;/div&gt;
&lt;div&gt;
else&lt;/div&gt;
&lt;div&gt;
x = z;&lt;/div&gt;
&lt;div&gt;
which will execute the if ( U ) when U is nonzero. We can also use if ( !U ) to represent&lt;/div&gt;
&lt;div&gt;
if ( U != 0 ) as well. Note that multiple expressions within the statement must be placed&lt;/div&gt;
&lt;div&gt;
within braces ({}) to represent a block. For example,&lt;/div&gt;
&lt;div&gt;
if ( U ) {&lt;/div&gt;
&lt;div&gt;
x = y;&lt;/div&gt;
&lt;div&gt;
z = 1;&lt;/div&gt;
&lt;div&gt;
} else {&lt;/div&gt;
&lt;div&gt;
x = z;&lt;/div&gt;
&lt;div&gt;
y = 1;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
A more compact form of the if statement involves using the ? operator. For example,&lt;/div&gt;
&lt;div&gt;
the following ifstatement&lt;/div&gt;
&lt;div&gt;
if ( y &amp;gt; z )&lt;/div&gt;
&lt;div&gt;
x = y;&lt;/div&gt;
&lt;div&gt;
else&lt;/div&gt;
&lt;div&gt;
x = z;&lt;/div&gt;
&lt;div&gt;
can be represented more compactly with&lt;/div&gt;
&lt;div&gt;
x = (y &amp;gt; z) ? y : z ;&lt;/div&gt;
&lt;div&gt;
The syntax is given by&lt;/div&gt;
&lt;div&gt;
expression1 ? expression2 : expression3&lt;/div&gt;
&lt;div&gt;
Which says evaluate expression1 first. If it is true, then evaluate and return expression2,&lt;/div&gt;
&lt;div&gt;
otherwise evaluate and return expression3.&lt;/div&gt;
&lt;div&gt;
Switch&lt;/div&gt;
&lt;div&gt;
Often you may have a particular variable whose value may take on several possibilities.&lt;/div&gt;
&lt;div&gt;
Rather than using an if statement, it is more convenient to use the switchstatement, for&lt;/div&gt;
&lt;div&gt;
which the syntax is given by&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
switch ( expression ) {&lt;/div&gt;
&lt;div&gt;
case const-expr:&lt;/div&gt;
&lt;div&gt;
statement&lt;/div&gt;
&lt;div&gt;
case const-expr:&lt;/div&gt;
&lt;div&gt;
statement&lt;/div&gt;
&lt;div&gt;
default:&lt;/div&gt;
&lt;div&gt;
statement&lt;/div&gt;
&lt;div&gt;
It is not necessary to employ the default statement, since if none of the cases are satisfied&lt;/div&gt;
&lt;div&gt;
then the statements will execute. As an example, consider the following switch statement&lt;/div&gt;
&lt;div&gt;
int i=25;&lt;/div&gt;
&lt;div&gt;
switch ( i ) {&lt;/div&gt;
&lt;div&gt;
case 25:&lt;/div&gt;
&lt;div&gt;
printf(&quot;i=25\n&quot;);&lt;/div&gt;
&lt;div&gt;
case 15:&lt;/div&gt;
&lt;div&gt;
printf(&quot;i=15\n&quot;);&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
This switch statement tests the value of i. If the first case is true, or when i==25, then&lt;/div&gt;
&lt;div&gt;
the first printf statement will be evaluated. But now that the first case has been satisfied,&lt;/div&gt;
&lt;div&gt;
all subsequent statements will be evaluated as well. That is, after one case is satisfied,&lt;/div&gt;
&lt;div&gt;
evaluation falls into the next case unless a break statement is issued. In the example given&lt;/div&gt;
&lt;div&gt;
above, since i==25, this code will print out both i=25 and i=15. To prevent this, you need&lt;/div&gt;
&lt;div&gt;
to use the break statement, as in&lt;/div&gt;
&lt;div&gt;
int i=25;&lt;/div&gt;
&lt;div&gt;
switch ( i ) {&lt;/div&gt;
&lt;div&gt;
case 25:&lt;/div&gt;
&lt;div&gt;
printf(&quot;i=25\n&quot;);&lt;/div&gt;
&lt;div&gt;
break;&lt;/div&gt;
&lt;div&gt;
case 15:&lt;/div&gt;
&lt;div&gt;
printf(&quot;i=15\n&quot;);&lt;/div&gt;
&lt;div&gt;
break;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
This will cause execution to break out of the switch statement after one of the cases is&lt;/div&gt;
&lt;div&gt;
satisfied.&lt;/div&gt;
&lt;div&gt;
For and while loops&lt;/div&gt;
&lt;div&gt;
The syntax of a while loop is given by&lt;/div&gt;
&lt;div&gt;
while ( expression )&lt;/div&gt;
&lt;div&gt;
statement&lt;/div&gt;
&lt;div&gt;
This will repeatedly evaluate statement as long as expression is true. For loops are just&lt;/div&gt;
&lt;div&gt;
special whileloops. The syntax of a for loop is given by&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
for ( expression1 ; expression2 ; expression3 )&lt;/div&gt;
&lt;div&gt;
statement&lt;/div&gt;
&lt;div&gt;
The equivalent while loop is given by&lt;/div&gt;
&lt;div&gt;
expression1;&lt;/div&gt;
&lt;div&gt;
while ( expression2 ) {&lt;/div&gt;
&lt;div&gt;
statement&lt;/div&gt;
&lt;div&gt;
expression3;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
As an example, consider the for loop which loops through the values of i and prints the&lt;/div&gt;
&lt;div&gt;
values&lt;/div&gt;
&lt;div&gt;
for(i=0;i&amp;lt;10;i++) {&lt;/div&gt;
&lt;div&gt;
printf(‘‘i=%d\n’’,i);&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
The equivalent while loop is&lt;/div&gt;
&lt;div&gt;
i=0;&lt;/div&gt;
&lt;div&gt;
while ( i &amp;lt; 10 ) {&lt;/div&gt;
&lt;div&gt;
printf(‘‘i=%d\n’’,i);&lt;/div&gt;
&lt;div&gt;
i++;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
Use of for or while for looping is purely a matter of preference, although some situations&lt;/div&gt;
&lt;div&gt;
are better suited to using for loops. The above example was clearly suited to using a for&lt;/div&gt;
&lt;div&gt;
loop since it looped through a specified set of values. At any time during the execution of&lt;/div&gt;
&lt;div&gt;
the for or while loops, you can stop the loop with the break command.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Arrays&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
Arrays are declared to store a certain number of variables of a specified type either on&lt;br /&gt;
the stack, which is the local static memory that is allocated to run your program when it&lt;br /&gt;
executes, or in the heap, which is memory that can be dynamically allocated and deallocated&lt;br /&gt;
as your program runs. To declare an array called values that contains 5 floating point&lt;br /&gt;
elements, you would use&lt;br /&gt;
float values[5];&lt;br /&gt;
This declaration requires that your program statically allocate a total of 20 bytes of memory&lt;br /&gt;
(5 floats × 4 bytes/float = 20 bytes) at runtime. You can also initialize arrays to contain&lt;br /&gt;
given values, such as&lt;br /&gt;
float values[] = {1,2,3,4,5};&lt;br /&gt;
which will allocate enough space to store the 5 numbers shown as floating point numbers.&lt;br /&gt;
You can access these values and print them, for example, in a loop, as follows&lt;br /&gt;
for(i=0;i&amp;lt;5;i++)&lt;br /&gt;
printf(‘‘%f\n’’,values[i]);&lt;br /&gt;
To declare multidimensional arrays on the stack, you would use&lt;br /&gt;
float values[5][3];&lt;br /&gt;
and you can access these values in a similar manner with&lt;br /&gt;
for(i=0;i&amp;lt;5;i++)&lt;br /&gt;
for(j=0;j&amp;lt;3;j++)&lt;br /&gt;
printf(‘‘%f\n’’,values[i][j]);&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Strings&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
Strings are character arrays that contain the null character ’\0’ as the final character. They&lt;br /&gt;
are NOT simply character arrays. It is important to understand the difference between a&lt;br /&gt;
simple array of characters and a string. An array of 5 characters is declared with&lt;br /&gt;
char string[5];&lt;br /&gt;
this is NOT a string until the last character is the null character, or unless&lt;br /&gt;
string[4]=’\0’;&lt;br /&gt;
Handout 8 17/03/03 2&lt;br /&gt;
If you attempted to print an array of characters that is not terminated with the null character,&lt;br /&gt;
then you get nonsense. Strings can be declared in a similar manner to arrays, as in&lt;br /&gt;
char string[] = ‘‘Hello!’’;&lt;br /&gt;
This is known as a declaration of a string constant. The string “Hello!” has a total of 6&lt;br /&gt;
characters, but the actual storage includes 7 characters, because the compiler adds on the&lt;br /&gt;
null character ’\0’. This is equivalent to the commands&lt;br /&gt;
char string[7];&lt;br /&gt;
string[0]=’H’;&lt;br /&gt;
string[1]=’e’;&lt;br /&gt;
string[2]=’l’;&lt;br /&gt;
string[3]=’l’;&lt;br /&gt;
string[4]=’o’;&lt;br /&gt;
string[6]=’!’;&lt;br /&gt;
string[7]=’\0’;&lt;br /&gt;
Note that since each element of a string is a character, if you wanted to determine whether&lt;br /&gt;
or not a particular string contained a given character, you would use a loop such as&lt;br /&gt;
i=0;&lt;br /&gt;
while(string[i++]!=’l’) ;&lt;br /&gt;
printf(‘‘Found c at location %d\n’’,i-1);&lt;br /&gt;
Functions for use with strings&lt;br /&gt;
The standard library string.h contains a host of commands that are very useful when&lt;br /&gt;
dealing with strings. To obtain the length of a string, you use&lt;br /&gt;
strlen(string);&lt;br /&gt;
This is useful when performing an operation on each individual character in a string, such&lt;br /&gt;
as&lt;br /&gt;
for(i=0;i&amp;lt;strlen(string);i++)&lt;br /&gt;
printf(‘‘%c\n’’,string[i]);&lt;br /&gt;
To copy the contents of one string into another, equating them does not work!. For&lt;br /&gt;
example, the following code will not work:&lt;br /&gt;
char string1[10], string2[10];&lt;br /&gt;
string2 = string1;&lt;br /&gt;
Instead, each character from string2 must be copied into string1 with&lt;br /&gt;
for(i=0;i&amp;lt;strlen(string1)+1;i++)&lt;br /&gt;
string2[i]=string1[i];&lt;br /&gt;
&lt;br /&gt;
Note that the for loop ends with the condition i&amp;lt;strlen(string1)+1 rather than with&lt;br /&gt;
i&amp;lt;strlen(string1) so that we can be sure to copy the null character. The standard library&lt;br /&gt;
string.h provides the useful function that does this for us as&lt;br /&gt;
strcpy(string2,string1);&lt;br /&gt;
which copies string1 into string2.&lt;br /&gt;
The other useful function (among many others) is strcmp, which enables us to compare&lt;br /&gt;
the equality of strings. This function is used as&lt;br /&gt;
if(strcmp(string1,string2)&amp;gt;0)&lt;br /&gt;
printf(‘‘string1 &amp;gt; string2\n’’);&lt;br /&gt;
else if(strcmp(string1,string2)==0)&lt;br /&gt;
printf(‘‘string1 == string2\n’’);&lt;br /&gt;
else if(strcmp(string1,string2)&amp;lt;0)&lt;br /&gt;
printf(‘‘string1 &amp;lt; string2\n’’);&lt;br /&gt;
The equality of string1 and string2 implies that they are identical, while if string1 is&lt;br /&gt;
less than string2, then string1 comes before string2 alphabetically, and vice-versa when&lt;br /&gt;
string1 is greater than string2.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Functions&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
Functions in C must be declared at the beginning of your source code. The format of a&lt;br /&gt;
declaration is given by&lt;br /&gt;
returntype FunctionName(argtype arg1, argtype arg2,...,etc...);&lt;br /&gt;
The actual function definition is declared in an identical manner with braces used to define&lt;br /&gt;
the function, as in&lt;br /&gt;
returntype FunctionName(argtype arg1, argtype arg2,...,etc...) {&lt;br /&gt;
returntype returnvariable;&lt;br /&gt;
code for function...&lt;br /&gt;
return returnvariable;&lt;br /&gt;
}&lt;br /&gt;
As an example, let’s say we would like to read in a string from the standard input and print&lt;br /&gt;
out the first location of a specified character in that string. The functions in the header file&lt;br /&gt;
/home/cos315/include/cos315.h&lt;br /&gt;
contain some useful operations and string types that we can use for these purposes. When&lt;br /&gt;
we discussed the declaration of strings before, the memory allocated for these strings was&lt;br /&gt;
all allocated on the stack. The functions in the cos315.h header file can be used to allocate&lt;br /&gt;
space for strings dynamically in the heap. To declare a string using this header file and&lt;br /&gt;
allocate space for it in the heap, we would use&lt;br /&gt;
&lt;br /&gt;
string line = NewString();&lt;br /&gt;
This uses the new type called string in the header file. We will discuss the details of this&lt;br /&gt;
declaration in more detail when we cover pointers in the next lecture. We need to be sure,&lt;br /&gt;
however, that every time we allocate something in dynamic memory that we free up the&lt;br /&gt;
memory associated with that string with&lt;br /&gt;
FreeString(line);&lt;br /&gt;
Once we allocate space for a string, we can read in a string from the command line with&lt;br /&gt;
GetLine(line,stdin);&lt;br /&gt;
which places the next line read in from stdin into the string line. The following code uses&lt;br /&gt;
these functions to create the find function which finds the location of the occurence of a&lt;br /&gt;
particular character in a given string.&lt;br /&gt;
&lt;br /&gt;
#include&amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &quot;cos315.h&quot;&lt;br /&gt;
#define TRUE 1&lt;br /&gt;
/*&lt;br /&gt;
* Function declarations.&lt;br /&gt;
*&lt;br /&gt;
*/&lt;br /&gt;
int find(string str, char c);&lt;br /&gt;
/*&lt;br /&gt;
* Main function.&lt;br /&gt;
*&lt;br /&gt;
*/&lt;br /&gt;
int main(void) {&lt;br /&gt;
int location;&lt;br /&gt;
char c = ’l’;&lt;br /&gt;
string line = NewString();&lt;br /&gt;
printf(&quot;Type quit to exit.\n&quot;);&lt;br /&gt;
while(TRUE) {&lt;br /&gt;
printf(&quot;String: &quot;);&lt;br /&gt;
GetLine(line,stdin);&lt;br /&gt;
if(!strcmp(line,&quot;quit\n&quot;))&lt;br /&gt;
exit(0);&lt;br /&gt;
location = find(line,c);&lt;br /&gt;
if(location == -1)&lt;br /&gt;
printf(&quot;Character %c not found in string %s\n&quot;,c,line);&lt;br /&gt;
else&lt;br /&gt;
printf(&quot;The character %c is located at index %d in string %s\n&quot;,&lt;br /&gt;
c,location,line);&lt;br /&gt;
}&lt;br /&gt;
FreeString(line);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
* Function: find&lt;br /&gt;
* Usage: loc=find(string,’c’);&lt;br /&gt;
* ----------------------------&lt;br /&gt;
* This function returns the first index at which the specified&lt;br /&gt;
* character exists in the given string. If it is not found&lt;br /&gt;
* then a -1 is returned.&lt;br /&gt;
*&lt;br /&gt;
*/&lt;br /&gt;
int find(string str, char c) {&lt;br /&gt;
int i;&lt;br /&gt;
for(i=0;i&amp;lt;strlen(str);i++)&lt;br /&gt;
if(str[i]==c)&lt;br /&gt;
return i;&lt;br /&gt;
return -1;&lt;br /&gt;
}&lt;br /&gt;
This code is available on the class server as the file&lt;br /&gt;
/home/cos315/assignments/assignment2/find.c&lt;br /&gt;
To compile this code, you need to link it with the precompiled object file on the class server&lt;br /&gt;
and you also need to tell it where to find the header file with the -I option, as in&lt;br /&gt;
$ gcc find.c /home/cos315/include/cos315.o -I/home/cos315/include&lt;br /&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bitslabs.blogspot.com/feeds/5046753146870313219/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bitslabs.blogspot.com/2012/04/c-programming.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6914906347289349334/posts/default/5046753146870313219'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6914906347289349334/posts/default/5046753146870313219'/><link rel='alternate' type='text/html' href='http://bitslabs.blogspot.com/2012/04/c-programming.html' title='C programming'/><author><name>Bits LAB</name><uri>http://www.blogger.com/profile/13420625091230869380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6914906347289349334.post-3053409851989857651</id><published>2012-04-13T00:23:00.000-07:00</published><updated>2012-04-13T00:23:12.145-07:00</updated><title type='text'>Your First Go Code</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;wide&quot; id=&quot;page&quot; style=&quot;clear: both; color: #222222; font-family: Helvetica, Arial, sans-serif; font-size: 16px; margin-left: auto; margin-right: auto; padding-bottom: 0px; padding-left: 20px; padding-right: 20px; padding-top: 0px; width: auto;&quot;&gt;
&lt;h1 style=&quot;color: #375eab; font-size: 24px; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
How to Write Go Code&lt;/h1&gt;
&lt;div id=&quot;nav&quot;&gt;
&lt;table class=&quot;unruled&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;first&quot; style=&quot;vertical-align: top;&quot;&gt;
&lt;dl style=&quot;font-size: 14px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
&lt;dt&gt;&lt;a href=&quot;http://golang.org/doc/code.html#Introduction&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Introduction&lt;/a&gt;&lt;/dt&gt;
&lt;dt&gt;&lt;a href=&quot;http://golang.org/doc/code.html#GOPATH&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Code organization&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/doc/code.html#tmp_13&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;GOPATH and workspaces&lt;/a&gt;&lt;/dd&gt;&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/doc/code.html#tmp_43&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Import paths&lt;/a&gt;&lt;/dd&gt;&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/doc/code.html#tmp_55&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Package names&lt;/a&gt;&lt;/dd&gt;
&lt;dt&gt;&lt;a href=&quot;http://golang.org/doc/code.html#tmp_79&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Building and installing&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/doc/code.html#tmp_85&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Building a package&lt;/a&gt;&lt;/dd&gt;&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/doc/code.html#tmp_101&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Building a command&lt;/a&gt;&lt;/dd&gt;
&lt;dt&gt;&lt;a href=&quot;http://golang.org/doc/code.html#Testing&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Testing&lt;/a&gt;&lt;/dt&gt;
&lt;dt&gt;&lt;a href=&quot;http://golang.org/doc/code.html#remote&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Remote packages&lt;/a&gt;&lt;/dt&gt;
&lt;dt&gt;&lt;a href=&quot;http://golang.org/doc/code.html#more&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Further reading&lt;/a&gt;&lt;/dt&gt;
&lt;/dl&gt;
&lt;/td&gt;&lt;td style=&quot;vertical-align: top;&quot;&gt;
&lt;dl style=&quot;font-size: 14px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;&lt;/dl&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;h2 id=&quot;Introduction&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #e0ebf5; background-image: initial; background-origin: initial; clear: right; color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 20px; padding-bottom: 2px; padding-left: 5px; padding-right: 5px; padding-top: 2px;&quot;&gt;
Introduction&lt;/h2&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
This document demonstrates the development of a simple Go package and introduces the&amp;nbsp;&lt;a href=&quot;http://golang.org/cmd/go/&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;go command&lt;/a&gt;, the standard way to fetch, build, and install Go packages and commands.&lt;/div&gt;
&lt;h2 id=&quot;GOPATH&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #e0ebf5; background-image: initial; background-origin: initial; clear: right; color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 20px; padding-bottom: 2px; padding-left: 5px; padding-right: 5px; padding-top: 2px;&quot;&gt;
Code organization&lt;/h2&gt;
&lt;h3 id=&quot;tmp_13&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;GOPATH&lt;/code&gt;&amp;nbsp;and workspaces&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
One of Go&#39;s design goals is to make writing software easier. To that end, the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;go&lt;/code&gt;&amp;nbsp;command doesn&#39;t use Makefiles or other configuration files to guide program construction. Instead, it uses the source code to find dependencies and determine build conditions. This means your source code and build scripts are always in sync; they are one and the same.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The one thing you must do is set a&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;GOPATH&lt;/code&gt;&amp;nbsp;environment variable.&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;GOPATH&lt;/code&gt;&amp;nbsp;tells the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;go&lt;/code&gt;&amp;nbsp;command (and other related tools) where to find and install the Go packages on your system.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;GOPATH&lt;/code&gt;&amp;nbsp;is a list of paths. It shares the syntax of your system&#39;s&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;PATH&lt;/code&gt;&amp;nbsp;environment variable. A typical&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;GOPATH&lt;/code&gt;&amp;nbsp;on a Unix system might look like this:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;GOPATH=/home/user/ext:/home/user/mygo
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
(On a Windows system use semicolons as the path separator instead of colons.)&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Each path in the list (in this case&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;/home/user/ext&lt;/code&gt;&amp;nbsp;or&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;/home/user/mygo&lt;/code&gt;) specifies the location of a&amp;nbsp;&lt;i&gt;workspace&lt;/i&gt;. A workspace contains Go source files and their associated package objects, and command executables. It has a prescribed structure of three subdirectories:&lt;/div&gt;
&lt;ul style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
&lt;li&gt;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;src&lt;/code&gt;&amp;nbsp;contains Go source files,&lt;/li&gt;
&lt;li&gt;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;pkg&lt;/code&gt;&amp;nbsp;contains compiled package objects, and&lt;/li&gt;
&lt;li&gt;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;bin&lt;/code&gt;&amp;nbsp;contains executable commands.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Subdirectories of the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;src&lt;/code&gt;&amp;nbsp;directory hold independent packages, and all source files (&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;.go&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;.c&lt;/code&gt;,&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;.h&lt;/code&gt;, and&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;.s&lt;/code&gt;) in each subdirectory are elements of that subdirectory&#39;s package.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
When building a program that imports the package &quot;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;widget&lt;/code&gt;&quot; the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;go&lt;/code&gt;&amp;nbsp;command looks for&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;src/pkg/widget&lt;/code&gt;&amp;nbsp;inside the Go root, and then—if the package source isn&#39;t found there—it searches for&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;src/widget&lt;/code&gt;&amp;nbsp;inside each workspace in order.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Multiple workspaces can offer some flexibility and convenience, but for now we&#39;ll concern ourselves with only a single workspace.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Let&#39;s work through a simple example. First, create a&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;$HOME/mygo&lt;/code&gt;&amp;nbsp;directory and its&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;src&lt;/code&gt;&amp;nbsp;subdirectory:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;$ mkdir -p $HOME/mygo/src # create a place to put source code
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Next, set it as the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;GOPATH&lt;/code&gt;. You should also add the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;bin&lt;/code&gt;&amp;nbsp;subdirectory to your&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;PATH&lt;/code&gt;&amp;nbsp;environment variable so that you can run the commands therein without specifying their full path. To do this, add the following lines to&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;$HOME/.profile&lt;/code&gt;&amp;nbsp;(or equivalent):&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;export GOPATH=$HOME/mygo
export PATH=$PATH:$HOME/mygo/bin
&lt;/pre&gt;
&lt;h3 id=&quot;tmp_43&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Import paths&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The standard packages are given short import paths such as&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;&quot;fmt&quot;&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;&quot;net/http&quot;&lt;/code&gt;&amp;nbsp;for convenience. For your own projects, it is important to choose a base import path that is unlikely to collide with future additions to the standard library or other external libraries.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The best way to choose an import path is to use the location of your version control repository. For instance, if your source repository is at&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;example.com&lt;/code&gt;&amp;nbsp;or&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;code.google.com/p/example&lt;/code&gt;, you should begin your package paths with that URL, as in &quot;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;example.com/foo/bar&lt;/code&gt;&quot; or &quot;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;code.google.com/p/example/foo/bar&lt;/code&gt;&quot;. Using this convention, the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;go&lt;/code&gt;&amp;nbsp;command can automatically check out and build the source code by its import path alone.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
If you don&#39;t intend to install your code in this way, you should at least use a unique prefix like &quot;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;widgets/&lt;/code&gt;&quot;, as in &quot;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;widgets/foo/bar&lt;/code&gt;&quot;. A good rule is to use a prefix such as your company or project name, since it is unlikely to be used by another group.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
We&#39;ll use&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;example/&lt;/code&gt;&amp;nbsp;as our base import path:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;$ mkdir -p $GOPATH/src/example
&lt;/pre&gt;
&lt;h3 id=&quot;tmp_55&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Package names&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The first statement in a Go source file should be&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;package &lt;i&gt;name&lt;/i&gt;
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
where&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;&lt;i&gt;name&lt;/i&gt;&lt;/code&gt;&amp;nbsp;is the package&#39;s default name for imports. (All files in a package must use the same&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;&lt;i&gt;name&lt;/i&gt;&lt;/code&gt;.)&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Go&#39;s convention is that the package name is the last element of the import path: the package imported as &quot;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;crypto/rot13&lt;/code&gt;&quot; should be named&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;rot13&lt;/code&gt;. There is no requirement that package names be unique across all packages linked into a single binary, only that the import paths (their full file names) be unique.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Create a new package under&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;example&lt;/code&gt;&amp;nbsp;called&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;newmath&lt;/code&gt;:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;$ cd $GOPATH/src/example
$ mkdir newmath
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Then create a file named&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;$GOPATH/src/example/newmath/sqrt.go&lt;/code&gt;&amp;nbsp;containing the following Go code:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;// Package newmath is a trivial example package.
package newmath

// Sqrt returns an approximation to the square root of x.
func Sqrt(x float64) float64 {
        // This is a terrible implementation.
        // Real code should import &quot;math&quot; and use math.Sqrt.
        z := 0.0
        for i := 0; i &amp;lt; 1000; i++ {
                z -= (z*z - x) / (2 * x)
        }
        return z
}
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
This package is imported by the path name of the directory it&#39;s in, starting after the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;src&lt;/code&gt;&amp;nbsp;component:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;import &quot;example/newmath&quot;
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
See&amp;nbsp;&lt;a href=&quot;http://golang.org/doc/effective_go.html#names&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Effective Go&lt;/a&gt;&amp;nbsp;to learn more about Go&#39;s naming conventions.&lt;/div&gt;
&lt;h2 id=&quot;tmp_79&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #e0ebf5; background-image: initial; background-origin: initial; clear: right; color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 20px; padding-bottom: 2px; padding-left: 5px; padding-right: 5px; padding-top: 2px;&quot;&gt;
Building and installing&lt;/h2&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;go&lt;/code&gt;&amp;nbsp;command comprises several subcommands, the most central being&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;install&lt;/code&gt;. Running&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;go install&amp;nbsp;&lt;i&gt;importpath&lt;/i&gt;&lt;/code&gt;&amp;nbsp;builds and installs a package and its dependencies.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
To &quot;install a package&quot; means to write the package object or executable command to the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;pkg&lt;/code&gt;&amp;nbsp;or&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;bin&lt;/code&gt;&amp;nbsp;subdirectory of the workspace in which the source resides.&lt;/div&gt;
&lt;h3 id=&quot;tmp_85&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Building a package&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
To build and install the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;newmath&lt;/code&gt;&amp;nbsp;package, type&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;$ go install example/newmath
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
This command will produce no output if the package and its dependencies are built and installed correctly.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
As a convenience, the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;go&lt;/code&gt;&amp;nbsp;command will assume the current directory if no import path is specified on the command line. This sequence of commands has the same affect as the one above:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;$ cd $GOPATH/src/example/newmath
$ go install
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The resulting workspace directory tree (assuming we&#39;re running Linux on a 64-bit system) looks like this:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;pkg/
    linux_amd64/
        example/
            newmath.a  # package object
src/
    example/
        newmath/
            sqrt.go    # package source
&lt;/pre&gt;
&lt;h3 id=&quot;tmp_101&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Building a command&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;go&lt;/code&gt;&amp;nbsp;command treats code belonging to&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;package main&lt;/code&gt;&amp;nbsp;as an executable command and installs the package binary to the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;GOPATH&lt;/code&gt;&#39;s&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;bin&lt;/code&gt;&amp;nbsp;subdirectory.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Add a command named&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;hello&lt;/code&gt;&amp;nbsp;to the source tree. First create the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;example/hello&lt;/code&gt;&amp;nbsp;directory:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;$ cd $GOPATH/src/example
$ mkdir hello
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Then create the file&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;$GOPATH/src/example/hello/hello.go&lt;/code&gt;&amp;nbsp;containing the following Go code.&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;// Hello is a trivial example of a main package.
package main

import (
        &quot;example/newmath&quot;
        &quot;fmt&quot;
)

func main() {
        fmt.Printf(&quot;Hello, world.  Sqrt(2) = %v\n&quot;, newmath.Sqrt(2))
}
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Next, run&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;go install&lt;/code&gt;, which builds and installs the binary to&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;$GOPATH/bin&lt;/code&gt;:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;$ go install example/hello
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
To run the program, invoke it by name as you would any other command:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;$ $GOPATH/bin/hello
Hello, world.  Sqrt(2) = 1.414213562373095
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
If you added&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;$HOME/mygo/bin&lt;/code&gt;&amp;nbsp;to your&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;PATH&lt;/code&gt;, you may omit the path to the executable:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;$ hello
Hello, world.  Sqrt(2) = 1.414213562373095
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The workspace directory tree now looks like this:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;bin/
    hello              # command executable
pkg/
    linux_amd64/ 
        example/
            newmath.a  # package object
src/
    example/
        hello/
            hello.go   # command source
        newmath/
            sqrt.go    # package source
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;go&lt;/code&gt;&amp;nbsp;command also provides a&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;build&lt;/code&gt;&amp;nbsp;command, which is like&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;install&lt;/code&gt;&amp;nbsp;except it builds all objects in a temporary directory and does not install them under&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;pkg&lt;/code&gt;&amp;nbsp;or&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;bin&lt;/code&gt;. When building a command an executable named after the last element of the import path is written to the current directory. When building a package,&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;go build&lt;/code&gt;&amp;nbsp;serves merely to test that the package and its dependencies can be built. (The resulting package object is thrown away.)&lt;/div&gt;
&lt;h2 id=&quot;Testing&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #e0ebf5; background-image: initial; background-origin: initial; clear: right; color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 20px; padding-bottom: 2px; padding-left: 5px; padding-right: 5px; padding-top: 2px;&quot;&gt;
Testing&lt;/h2&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Go has a lightweight test framework composed of the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;go test&lt;/code&gt;&amp;nbsp;command and the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;testing&lt;/code&gt;&amp;nbsp;package.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
You write a test by creating a file with a name ending in&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;_test.go&lt;/code&gt;&amp;nbsp;that contains functions named&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;TestXXX&lt;/code&gt;&amp;nbsp;with signature&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;func (t *testing.T)&lt;/code&gt;. The test framework runs each such function; if the function calls a failure function such as&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;t.Error&lt;/code&gt;&amp;nbsp;or&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;t.Fail&lt;/code&gt;, the test is considered to have failed.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Add a test to the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;newmath&lt;/code&gt;&amp;nbsp;package by creating the file&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;$GOPATH/src/example/newmath/sqrt_test.go&lt;/code&gt;&amp;nbsp;containing the following Go code.&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;package newmath

import &quot;testing&quot;

func TestSqrt(t *testing.T) {
 const in, out = 9, 3
 if x := Sqrt(in); x != out {
  t.Errorf(&quot;Sqrt(%v) = %v, want %v&quot;, in, x, out)
        }
}
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Now run the test with&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;go test&lt;/code&gt;:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;$ go test example/newmath
ok   example/newmath
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Run&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;&lt;a href=&quot;http://golang.org/cmd/go/#Test_packages&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;go help test&lt;/a&gt;&lt;/code&gt;&amp;nbsp;and see the&amp;nbsp;&lt;a href=&quot;http://golang.org/pkg/testing/&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;testing package documentation&lt;/a&gt;&amp;nbsp;for more detail.&lt;/div&gt;
&lt;h2 id=&quot;remote&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #e0ebf5; background-image: initial; background-origin: initial; clear: right; color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 20px; padding-bottom: 2px; padding-left: 5px; padding-right: 5px; padding-top: 2px;&quot;&gt;
Remote packages&lt;/h2&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
An import path can describe how to obtain the package source code using a revision control system such as Git or Mercurial. The&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;go&lt;/code&gt;&amp;nbsp;command uses this property to automatically fetch packages from remote repositories. For instance, the examples described in this document are also kept in a Mercurial repository hosted at Google Code,&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;&lt;a href=&quot;http://code.google.com/p/go.example&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;code.google.com/p/go.example&lt;/a&gt;&lt;/code&gt;. If you include the repository URL in the package&#39;s import path,&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;go get&lt;/code&gt;&amp;nbsp;will fetch, build, and install it automatically:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;$ go get code.google.com/p/go.example/hello
$ $GOPATH/bin/hello
Hello, world.  Sqrt(2) = 1.414213562373095
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
If the specified package is not present in a workspace,&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;go get&lt;/code&gt;&amp;nbsp;will place it inside the first workspace specified by&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;GOPATH&lt;/code&gt;. (If the package does already exist,&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;go get&lt;/code&gt;&amp;nbsp;skips the remote fetch and behaves the same as&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;go install&lt;/code&gt;.)&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
After issuing the above&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;go get&lt;/code&gt;&amp;nbsp;command, the workspace directory tree should now now look like this:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;bin/
    hello                 # command executable
pkg/
    linux_amd64/ 
        code.google.com/p/go.example/
            newmath.a     # package object
        example/
            newmath.a     # package object
src/
    code.google.com/p/go.example/
        hello/
            hello.go      # command source
        newmath/
            sqrt.go       # package source
            sqrt_test.go  # test source
    example/
        hello/
            hello.go      # command source
        newmath/
            sqrt.go       # package source
            sqrt_test.go  # test source
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;hello&lt;/code&gt;&amp;nbsp;command hosted at Google Code depends on the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;newmath&lt;/code&gt;&amp;nbsp;package within the same repository. The imports in&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;hello.go&lt;/code&gt;&amp;nbsp;file use the same import path convention, so the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;go get&lt;/code&gt;&amp;nbsp;command is able to locate and install the dependent package, too.&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;import &quot;code.google.com/p/go.example/newmath&quot;
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
This convention is the easiest way to make your Go packages available for others to use. The&amp;nbsp;&lt;a href=&quot;http://godashboard.appspot.com/package&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Go Package Dashboard&lt;/a&gt;&amp;nbsp;displays a list of packages recently installed with the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;go&lt;/code&gt;command.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
For more information on using remote repositories with the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;go&lt;/code&gt;&amp;nbsp;command, see&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;&lt;a href=&quot;http://golang.org/cmd/go/#Remote_import_path_syntax&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;go help remote&lt;/a&gt;&lt;/code&gt;.&lt;/div&gt;
&lt;h2 id=&quot;more&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #e0ebf5; background-image: initial; background-origin: initial; clear: right; color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 20px; padding-bottom: 2px; padding-left: 5px; padding-right: 5px; padding-top: 2px;&quot;&gt;
Further reading&lt;/h2&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
See&amp;nbsp;&lt;a href=&quot;http://golang.org/doc/effective_go.html&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Effective Go&lt;/a&gt;&amp;nbsp;for tips on writing clear, idiomatic Go code.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Take&amp;nbsp;&lt;a href=&quot;http://tour.golang.org/&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;A Tour of Go&lt;/a&gt;&amp;nbsp;to learn the language proper.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Visit the&amp;nbsp;&lt;a href=&quot;http://golang.org/doc/#articles&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;documentation page&lt;/a&gt;&amp;nbsp;for a set of in-depth articles about the Go language and its libraries and tools.&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&quot;footer&quot; style=&quot;color: #666666; font-family: Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 40px; margin-left: 0px; margin-right: 0px; margin-top: 40px; text-align: center;&quot;&gt;
Build version go1.&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bitslabs.blogspot.com/feeds/3053409851989857651/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bitslabs.blogspot.com/2012/04/your-first-go-code.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6914906347289349334/posts/default/3053409851989857651'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6914906347289349334/posts/default/3053409851989857651'/><link rel='alternate' type='text/html' href='http://bitslabs.blogspot.com/2012/04/your-first-go-code.html' title='Your First Go Code'/><author><name>Bits LAB</name><uri>http://www.blogger.com/profile/13420625091230869380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6914906347289349334.post-2908182447669917322</id><published>2012-04-13T00:20:00.001-07:00</published><updated>2012-04-13T00:24:46.008-07:00</updated><title type='text'>Command go</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;wide&quot; id=&quot;page&quot; style=&quot;clear: both; color: #222222; font-family: Helvetica, Arial, sans-serif; font-size: 16px; margin-left: auto; margin-right: auto; padding-bottom: 0px; padding-left: 20px; padding-right: 20px; padding-top: 0px; width: auto;&quot;&gt;
&lt;h1 style=&quot;color: #375eab; font-size: 24px; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Command go&lt;/h1&gt;
&lt;div id=&quot;nav&quot;&gt;
&lt;table class=&quot;unruled&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;first&quot; style=&quot;vertical-align: top;&quot;&gt;
&lt;dl style=&quot;font-size: 14px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/cmd/go/#Compile_packages_and_dependencies&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Compile packages and dependencies&lt;/a&gt;&lt;/dd&gt;&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/cmd/go/#Remove_object_files&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Remove object files&lt;/a&gt;&lt;/dd&gt;&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/cmd/go/#Run_godoc_on_package_sources&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Run godoc on package sources&lt;/a&gt;&lt;/dd&gt;&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/cmd/go/#Print_Go_environment_information&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Print Go environment information&lt;/a&gt;&lt;/dd&gt;&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/cmd/go/#Run_go_tool_fix_on_packages&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Run go tool fix on packages&lt;/a&gt;&lt;/dd&gt;&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/cmd/go/#Run_gofmt_on_package_sources&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Run gofmt on package sources&lt;/a&gt;&lt;/dd&gt;&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/cmd/go/#Download_and_install_packages_and_dependencies&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Download and install packages and dependencies&lt;/a&gt;&lt;/dd&gt;&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/cmd/go/#Compile_and_install_packages_and_dependencies&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Compile and install packages and dependencies&lt;/a&gt;&lt;/dd&gt;&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/cmd/go/#List_packages&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;List packages&lt;/a&gt;&lt;/dd&gt;&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/cmd/go/#Compile_and_run_Go_program&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Compile and run Go program&lt;/a&gt;&lt;/dd&gt;&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/cmd/go/#Test_packages&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Test packages&lt;/a&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;/td&gt;&lt;td style=&quot;vertical-align: top;&quot;&gt;
&lt;dl style=&quot;font-size: 14px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/cmd/go/#Run_specified_go_tool&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Run specified go tool&lt;/a&gt;&lt;/dd&gt;&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/cmd/go/#Print_Go_version&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Print Go version&lt;/a&gt;&lt;/dd&gt;&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/cmd/go/#Run_go_tool_vet_on_packages&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Run go tool vet on packages&lt;/a&gt;&lt;/dd&gt;&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/cmd/go/#GOPATH_environment_variable&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;GOPATH environment variable&lt;/a&gt;&lt;/dd&gt;&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/cmd/go/#Description_of_package_lists&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Description of package lists&lt;/a&gt;&lt;/dd&gt;&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/cmd/go/#Remote_import_path_syntax&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Remote import path syntax&lt;/a&gt;&lt;/dd&gt;&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/cmd/go/#Description_of_testing_flags&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Description of testing flags&lt;/a&gt;&lt;/dd&gt;&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/cmd/go/#Description_of_testing_functions&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Description of testing functions&lt;/a&gt;&lt;/dd&gt;&lt;/dl&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Go is a tool for managing Go source code.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Usage:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;go command [arguments]
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The commands are:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;build       compile packages and dependencies
clean       remove object files
doc         run godoc on package sources
env         print Go environment information
fix         run go tool fix on packages
fmt         run gofmt on package sources
get         download and install packages and dependencies
install     compile and install packages and dependencies
list        list packages
run         compile and run Go program
test        test packages
tool        run specified go tool
version     print Go version
vet         run go tool vet on packages
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Use &quot;go help [command]&quot; for more information about a command.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Additional help topics:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;gopath      GOPATH environment variable
packages    description of package lists
remote      remote import path syntax
testflag    description of testing flags
testfunc    description of testing functions
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Use &quot;go help [topic]&quot; for more information about that topic.&lt;/div&gt;
&lt;h3 id=&quot;Compile_packages_and_dependencies&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Compile packages and dependencies&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Usage:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;go build [-o output] [build flags] [packages]
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Build compiles the packages named by the import paths, along with their dependencies, but it does not install the results.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
If the arguments are a list of .go files, build treats them as a list of source files specifying a single package.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
When the command line specifies a single main package, build writes the resulting executable to output. Otherwise build compiles the packages but discards the results, serving only as a check that the packages can be built.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The -o flag specifies the output file name. If not specified, the name is packagename.a (for a non-main package) or the base name of the first source file (for a main package).&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The build flags are shared by the build, install, run, and test commands:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;-a
 force rebuilding of packages that are already up-to-date.
-n
 print the commands but do not run them.
-p n
 the number of builds that can be run in parallel.
 The default is the number of CPUs available.
-v
 print the names of packages as they are compiled.
-work
 print the name of the temporary work directory and
 do not delete it when exiting.
-x
 print the commands.

-compiler name
 name of compiler to use, as in runtime.Compiler (gccgo or gc)
-gccgoflags &#39;arg list&#39;
 arguments to pass on each gccgo compiler/linker invocation
-gcflags &#39;arg list&#39;
 arguments to pass on each 5g, 6g, or 8g compiler invocation
-ldflags &#39;flag list&#39;
 arguments to pass on each 5l, 6l, or 8l linker invocation
-tags &#39;tag list&#39;
 a list of build tags to consider satisfied during the build.
 See the documentation for the go/build package for
 more information about build tags.
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
For more about specifying packages, see &#39;go help packages&#39;. For more about where packages and binaries are installed, see &#39;go help gopath&#39;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
See also: go install, go get, go clean.&lt;/div&gt;
&lt;h3 id=&quot;Remove_object_files&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Remove object files&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Usage:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;go clean [-i] [-r] [-n] [-x] [packages]
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Clean removes object files from package source directories. The go command builds most objects in a temporary directory, so go clean is mainly concerned with object files left by other tools or by manual invocations of go build.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Specifically, clean removes the following files from each of the source directories corresponding to the import paths:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;_obj/            old object directory, left from Makefiles
_test/           old test directory, left from Makefiles
_testmain.go     old gotest file, left from Makefiles
test.out         old test log, left from Makefiles
build.out        old test log, left from Makefiles
*.[568ao]        object files, left from Makefiles

DIR(.exe)        from go build
DIR.test(.exe)   from go test -c
MAINFILE(.exe)   from go build MAINFILE.go
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
In the list, DIR represents the final path element of the directory, and MAINFILE is the base name of any Go source file in the directory that is not included when building the package.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The -i flag causes clean to remove the corresponding installed archive or binary (what &#39;go install&#39; would create).&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The -n flag causes clean to print the remove commands it would execute, but not run them.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The -r flag causes clean to be applied recursively to all the dependencies of the packages named by the import paths.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The -x flag causes clean to print remove commands as it executes them.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
For more about specifying packages, see &#39;go help packages&#39;.&lt;/div&gt;
&lt;h3 id=&quot;Run_godoc_on_package_sources&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Run godoc on package sources&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Usage:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;go doc [packages]
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Doc runs the godoc command on the packages named by the import paths.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
For more about godoc, see &#39;godoc godoc&#39;. For more about specifying packages, see &#39;go help packages&#39;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
To run godoc with specific options, run godoc itself.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
See also: go fix, go fmt, go vet.&lt;/div&gt;
&lt;h3 id=&quot;Print_Go_environment_information&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Print Go environment information&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Usage:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;go env [var ...]
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Env prints Go environment information.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
By default env prints information as a shell script (on Windows, a batch file). If one or more variable names is given as arguments, env prints the value of each named variable on its own line.&lt;/div&gt;
&lt;h3 id=&quot;Run_go_tool_fix_on_packages&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Run go tool fix on packages&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Usage:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;go fix [packages]
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Fix runs the Go fix command on the packages named by the import paths.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
For more about fix, see &#39;godoc fix&#39;. For more about specifying packages, see &#39;go help packages&#39;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
To run fix with specific options, run &#39;go tool fix&#39;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
See also: go fmt, go vet.&lt;/div&gt;
&lt;h3 id=&quot;Run_gofmt_on_package_sources&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Run gofmt on package sources&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Usage:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;go fmt [packages]
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Fmt runs the command &#39;gofmt -l -w&#39; on the packages named by the import paths. It prints the names of the files that are modified.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
For more about gofmt, see &#39;godoc gofmt&#39;. For more about specifying packages, see &#39;go help packages&#39;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
To run gofmt with specific options, run gofmt itself.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
See also: go doc, go fix, go vet.&lt;/div&gt;
&lt;h3 id=&quot;Download_and_install_packages_and_dependencies&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Download and install packages and dependencies&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Usage:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;go get [-a] [-d] [-fix] [-n] [-p n] [-u] [-v] [-x] [packages]
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Get downloads and installs the packages named by the import paths, along with their dependencies.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The -a, -n, -v, -x, and -p flags have the same meaning as in &#39;go build&#39; and &#39;go install&#39;. See &#39;go help build&#39;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The -d flag instructs get to stop after downloading the packages; that is, it instructs get not to install the packages.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The -fix flag instructs get to run the fix tool on the downloaded packages before resolving dependencies or building the code.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The -u flag instructs get to use the network to update the named packages and their dependencies. By default, get uses the network to check out missing packages but does not use it to look for updates to existing packages.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
When checking out or updating a package, get looks for a branch or tag that matches the locally installed version of Go. If the local version &quot;is release.rNN&quot;, it searches for &quot;go.rNN&quot;. (For an installation using Go version &quot;weekly.YYYY-MM-DD&quot;, it searches for a package version labeled &quot;go.YYYY-MM-DD&quot;.) If the desired version cannot be found but others exist with labels in the correct format, get retrieves the most recent version before the desired label. Finally, if all else fails it retrieves the most recent version of the package.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
For more about specifying packages, see &#39;go help packages&#39;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
For more about how &#39;go get&#39; finds source code to download, see &#39;go help remote&#39;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
See also: go build, go install, go clean.&lt;/div&gt;
&lt;h3 id=&quot;Compile_and_install_packages_and_dependencies&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Compile and install packages and dependencies&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Usage:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;go install [build flags] [packages]
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Install compiles and installs the packages named by the import paths, along with their dependencies.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
For more about the build flags, see &#39;go help build&#39;. For more about specifying packages, see &#39;go help packages&#39;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
See also: go build, go get, go clean.&lt;/div&gt;
&lt;h3 id=&quot;List_packages&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
List packages&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Usage:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;go list [-e] [-f format] [-json] [packages]
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
List lists the packages named by the import paths, one per line.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The default output shows the package import path:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;code.google.com/p/google-api-go-client/books/v1
code.google.com/p/goauth2/oauth
code.google.com/p/sqlite
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The -f flag specifies an alternate format for the list, using the syntax of package template. The default output is equivalent to -f &#39;{{.ImportPath}}&#39;. The struct being passed to the template is:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;type Package struct {
    Dir        string // directory containing package sources
    ImportPath string // import path of package in dir
    Name       string // package name
    Doc        string // package documentation string
    Target     string // install path
    Goroot     bool   // is this package in the Go root?
    Standard   bool   // is this package part of the standard Go library?
    Stale      bool   // would &#39;go install&#39; do anything for this package?
    Root       string // Go root or Go path dir containing this package

    // Source files
    GoFiles  []string  // .go source files (excluding CgoFiles, TestGoFiles, XTestGoFiles)
    CgoFiles []string  // .go sources files that import &quot;C&quot;
    CFiles   []string  // .c source files
    HFiles   []string  // .h source files
    SFiles   []string  // .s source files
    SysoFiles []string // .syso object files to add to archive

    // Cgo directives
    CgoCFLAGS    []string // cgo: flags for C compiler
    CgoLDFLAGS   []string // cgo: flags for linker
    CgoPkgConfig []string // cgo: pkg-config names

    // Dependency information
    Imports []string // import paths used by this package
    Deps    []string // all (recursively) imported dependencies

    // Error information
    Incomplete bool            // this package or a dependency has an error
    Error      *PackageError   // error loading package
    DepsErrors []*PackageError // errors loading dependencies

    TestGoFiles  []string // _test.go files in package
    TestImports  []string // imports from TestGoFiles
    XTestGoFiles []string // _test.go files outside package
    XTestImports []string // imports from XTestGoFiles
}
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The -json flag causes the package data to be printed in JSON format instead of using the template format.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The -e flag changes the handling of erroneous packages, those that cannot be found or are malformed. By default, the list command prints an error to standard error for each erroneous package and omits the packages from consideration during the usual printing. With the -e flag, the list command never prints errors to standard error and instead processes the erroneous packages with the usual printing. Erroneous packages will have a non-empty ImportPath and a non-nil Error field; other information may or may not be missing (zeroed).&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
For more about specifying packages, see &#39;go help packages&#39;.&lt;/div&gt;
&lt;h3 id=&quot;Compile_and_run_Go_program&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Compile and run Go program&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Usage:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;go run [build flags] gofiles... [arguments...]
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Run compiles and runs the main package comprising the named Go source files.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
For more about build flags, see &#39;go help build&#39;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
See also: go build.&lt;/div&gt;
&lt;h3 id=&quot;Test_packages&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Test packages&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Usage:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;go test [-c] [-i] [build flags] [packages] [flags for test binary]
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
&#39;Go test&#39; automates testing the packages named by the import paths. It prints a summary of the test results in the format:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;ok   archive/tar   0.011s
FAIL archive/zip   0.022s
ok   compress/gzip 0.033s
...
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
followed by detailed output for each failed package.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
&#39;Go test&#39; recompiles each package along with any files with names matching the file pattern &quot;*_test.go&quot;. These additional files can contain test functions, benchmark functions, and example functions. See &#39;go help testfunc&#39; for more.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
By default, go test needs no arguments. It compiles and tests the package with source in the current directory, including tests, and runs the tests.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The package is built in a temporary directory so it does not interfere with the non-test installation.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
In addition to the build flags, the flags handled by &#39;go test&#39; itself are:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;-c  Compile the test binary to pkg.test but do not run it.

-i
    Install packages that are dependencies of the test.
    Do not run the test.
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The test binary also accepts flags that control execution of the test; these flags are also accessible by &#39;go test&#39;. See &#39;go help testflag&#39; for details.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
For more about build flags, see &#39;go help build&#39;. For more about specifying packages, see &#39;go help packages&#39;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
See also: go build, go vet.&lt;/div&gt;
&lt;h3 id=&quot;Run_specified_go_tool&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Run specified go tool&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Usage:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;go tool [-n] command [args...]
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Tool runs the go tool command identified by the arguments. With no arguments it prints the list of known tools.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The -n flag causes tool to print the command that would be executed but not execute it.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
For more about each tool command, see &#39;go tool command -h&#39;.&lt;/div&gt;
&lt;h3 id=&quot;Print_Go_version&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Print Go version&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Usage:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;go version
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Version prints the Go version, as reported by runtime.Version.&lt;/div&gt;
&lt;h3 id=&quot;Run_go_tool_vet_on_packages&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Run go tool vet on packages&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Usage:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;go vet [packages]
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Vet runs the Go vet command on the packages named by the import paths.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
For more about vet, see &#39;godoc vet&#39;. For more about specifying packages, see &#39;go help packages&#39;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
To run the vet tool with specific options, run &#39;go tool vet&#39;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
See also: go fmt, go fix.&lt;/div&gt;
&lt;h3 id=&quot;GOPATH_environment_variable&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
GOPATH environment variable&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The Go path is used to resolve import statements. It is implemented by and documented in the go/build package.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The GOPATH environment variable lists places to look for Go code. On Unix, the value is a colon-separated string. On Windows, the value is a semicolon-separated string. On Plan 9, the value is a list.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
GOPATH must be set to build and install packages outside the standard Go tree.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Each directory listed in GOPATH must have a prescribed structure:&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The src/ directory holds source code. The path below &#39;src&#39; determines the import path or executable name.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The pkg/ directory holds installed package objects. As in the Go tree, each target operating system and architecture pair has its own subdirectory of pkg (pkg/GOOS_GOARCH).&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
If DIR is a directory listed in the GOPATH, a package with source in DIR/src/foo/bar can be imported as &quot;foo/bar&quot; and has its compiled form installed to &quot;DIR/pkg/GOOS_GOARCH/foo/bar.a&quot;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The bin/ directory holds compiled commands. Each command is named for its source directory, but only the final element, not the entire path. That is, the command with source in DIR/src/foo/quux is installed into DIR/bin/quux, not DIR/bin/foo/quux. The foo/ is stripped so that you can add DIR/bin to your PATH to get at the installed commands. If the GOBIN environment variable is set, commands are installed to the directory it names instead of DIR/bin.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Here&#39;s an example directory layout:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;GOPATH=/home/user/gocode

/home/user/gocode/
    src/
        foo/
            bar/               (go code in package bar)
                x.go
            quux/              (go code in package main)
                y.go
    bin/
        quux                   (installed command)
    pkg/
        linux_amd64/
            foo/
                bar.a          (installed package object)
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Go searches each directory listed in GOPATH to find source code, but new packages are always downloaded into the first directory in the list.&lt;/div&gt;
&lt;h3 id=&quot;Description_of_package_lists&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Description of package lists&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Many commands apply to a set of packages:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;go action [packages]
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Usually, [packages] is a list of import paths.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
An import path that is a rooted path or that begins with a . or .. element is interpreted as a file system path and denotes the package in that directory.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Otherwise, the import path P denotes the package found in the directory DIR/src/P for some DIR listed in the GOPATH environment variable (see &#39;go help gopath&#39;).&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
If no import paths are given, the action applies to the package in the current directory.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The special import path &quot;all&quot; expands to all package directories found in all the GOPATH trees. For example, &#39;go list all&#39; lists all the packages on the local system.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The special import path &quot;std&quot; is like all but expands to just the packages in the standard Go library.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
An import path is a pattern if it includes one or more &quot;...&quot; wildcards, each of which can match any string, including the empty string and strings containing slashes. Such a pattern expands to all package directories found in the GOPATH trees with names matching the patterns. As a special case, x/... matches x as well as x&#39;s subdirectories. For example, net/... expands to net and packages in its subdirectories.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
An import path can also name a package to be downloaded from a remote repository. Run &#39;go help remote&#39; for details.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Every package in a program must have a unique import path. By convention, this is arranged by starting each path with a unique prefix that belongs to you. For example, paths used internally at Google all begin with &#39;google&#39;, and paths denoting remote repositories begin with the path to the code, such as &#39;code.google.com/p/project&#39;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
As a special case, if the package list is a list of .go files from a single directory, the command is applied to a single synthesized package made up of exactly those files, ignoring any build constraints in those files and ignoring any other files in the directory.&lt;/div&gt;
&lt;h3 id=&quot;Remote_import_path_syntax&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Remote import path syntax&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
An import path (see &#39;go help importpath&#39;) denotes a package stored in the local file system. Certain import paths also describe how to obtain the source code for the package using a revision control system.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
A few common code hosting sites have special syntax:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;BitBucket (Mercurial)

 import &quot;bitbucket.org/user/project&quot;
 import &quot;bitbucket.org/user/project/sub/directory&quot;

GitHub (Git)

 import &quot;github.com/user/project&quot;
 import &quot;github.com/user/project/sub/directory&quot;

Google Code Project Hosting (Git, Mercurial, Subversion)

 import &quot;code.google.com/p/project&quot;
 import &quot;code.google.com/p/project/sub/directory&quot;

 import &quot;code.google.com/p/project.subrepository&quot;
 import &quot;code.google.com/p/project.subrepository/sub/directory&quot;

Launchpad (Bazaar)

 import &quot;launchpad.net/project&quot;
 import &quot;launchpad.net/project/series&quot;
 import &quot;launchpad.net/project/series/sub/directory&quot;

 import &quot;launchpad.net/~user/project/branch&quot;
 import &quot;launchpad.net/~user/project/branch/sub/directory&quot;
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
For code hosted on other servers, import paths may either be qualified with the version control type, or the go tool can dynamically fetch the import path over https/http and discover where the code resides from a &amp;lt;meta&amp;gt; tag in the HTML.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
To declare the code location, an import path of the form&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;repository.vcs/path
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
specifies the given repository, with or without the .vcs suffix, using the named version control system, and then the path inside that repository. The supported version control systems are:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;Bazaar      .bzr
Git         .git
Mercurial   .hg
Subversion  .svn
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
For example,&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;import &quot;example.org/user/foo.hg&quot;
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
denotes the root directory of the Mercurial repository at example.org/user/foo or foo.hg, and&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;import &quot;example.org/repo.git/foo/bar&quot;
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
denotes the foo/bar directory of the Git repository at example.com/repo or repo.git.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
When a version control system supports multiple protocols, each is tried in turn when downloading. For example, a Git download tries git://, then https://, then http://.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
If the import path is not a known code hosting site and also lacks a version control qualifier, the go tool attempts to fetch the import over https/http and looks for a &amp;lt;meta&amp;gt; tag in the document&#39;s HTML &amp;lt;head&amp;gt;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The meta tag has the form:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&amp;lt;meta name=&quot;go-import&quot; content=&quot;import-prefix vcs repo-root&quot;&amp;gt;
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The import-prefix is the import path correponding to the repository root. It must be a prefix or an exact match of the package being fetched with &quot;go get&quot;. If it&#39;s not an exact match, another http request is made at the prefix to verify the &amp;lt;meta&amp;gt; tags match.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The vcs is one of &quot;git&quot;, &quot;hg&quot;, &quot;svn&quot;, etc,&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The repo-root is the root of the version control system containing a scheme and not containing a .vcs qualifier.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
For example,&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;import &quot;example.org/pkg/foo&quot;
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
will result in the following request(s):&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;a href=&quot;https://example.org/pkg/foo?go-get=1&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;https://example.org/pkg/foo?go-get=1&lt;/a&gt; (preferred)
&lt;a href=&quot;http://example.org/pkg/foo?go-get=1&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;http://example.org/pkg/foo?go-get=1&lt;/a&gt;  (fallback)
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
If that page contains the meta tag&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&amp;lt;meta name=&quot;go-import&quot; content=&quot;example.org git &lt;a href=&quot;https://code.org/r/p/exproj&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;https://code.org/r/p/exproj&lt;/a&gt;&quot;&amp;gt;
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
the go tool will verify that&amp;nbsp;&lt;a href=&quot;https://example.org/?go-get=1&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;https://example.org/?go-get=1&lt;/a&gt;&amp;nbsp;contains the same meta tag and then git clone&amp;nbsp;&lt;a href=&quot;https://code.org/r/p/exproj&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;https://code.org/r/p/exproj&lt;/a&gt;&amp;nbsp;into GOPATH/src/example.org.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
New downloaded packages are written to the first directory listed in the GOPATH environment variable (see &#39;go help gopath&#39;).&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The go command attempts to download the version of the package appropriate for the Go release being used. Run &#39;go help install&#39; for more.&lt;/div&gt;
&lt;h3 id=&quot;Description_of_testing_flags&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Description of testing flags&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The &#39;go test&#39; command takes both flags that apply to &#39;go test&#39; itself and flags that apply to the resulting test binary.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The test binary, called pkg.test, where pkg is the name of the directory containing the package sources, has its own flags:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;-test.v
    Verbose output: log all tests as they are run.

-test.run pattern
    Run only those tests and examples matching the regular
    expression.

-test.bench pattern
    Run benchmarks matching the regular expression.
    By default, no benchmarks run.

-test.cpuprofile cpu.out
    Write a CPU profile to the specified file before exiting.

-test.memprofile mem.out
    Write a memory profile to the specified file when all tests
    are complete.

-test.memprofilerate n
    Enable more precise (and expensive) memory profiles by setting
    runtime.MemProfileRate.  See &#39;godoc runtime MemProfileRate&#39;.
    To profile all memory allocations, use -test.memprofilerate=1
    and set the environment variable GOGC=off to disable the
    garbage collector, provided the test can run in the available
    memory without garbage collection.

-test.parallel n
    Allow parallel execution of test functions that call t.Parallel.
    The value of this flag is the maximum number of tests to run
    simultaneously; by default, it is set to the value of GOMAXPROCS.

-test.short
    Tell long-running tests to shorten their run time.
    It is off by default but set during all.bash so that installing
    the Go tree can run a sanity check but not spend time running
    exhaustive tests.

-test.timeout t
 If a test runs longer than t, panic.

-test.benchtime n
 Run enough iterations of each benchmark to take n seconds.
 The default is 1 second.

-test.cpu 1,2,4
    Specify a list of GOMAXPROCS values for which the tests or
    benchmarks should be executed.  The default is the current value
    of GOMAXPROCS.
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
For convenience, each of these -test.X flags of the test binary is also available as the flag -X in &#39;go test&#39; itself. Flags not listed here are passed through unaltered. For instance, the command&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;go test -x -v -cpuprofile=prof.out -dir=testdata -update
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
will compile the test binary and then run it as&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;pkg.test -test.v -test.cpuprofile=prof.out -dir=testdata -update
&lt;/pre&gt;
&lt;h3 id=&quot;Description_of_testing_functions&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;
Description of testing functions&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The &#39;go test&#39; command expects to find test, benchmark, and example functions in the &quot;*_test.go&quot; files corresponding to the package under test.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
A test function is one named TestXXX (where XXX is any alphanumeric string not starting with a lower case letter) and should have the signature,&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;func TestXXX(t *testing.T) { ... }
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
A benchmark function is one named BenchmarkXXX and should have the signature,&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;func BenchmarkXXX(b *testing.B) { ... }
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
An example function is similar to a test function but, instead of using *testing.T to report success or failure, prints output to os.Stdout and os.Stderr. That output is compared against the function&#39;s &quot;Output:&quot; comment, which must be the last comment in the function body (see example below). An example with no such comment, or with no text after &quot;Output:&quot; is compiled but not executed.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Godoc displays the body of ExampleXXX to demonstrate the use of the function, constant, or variable XXX. An example of a method M with receiver type T or *T is named ExampleT_M. There may be multiple examples for a given function, constant, or variable, distinguished by a trailing _xxx, where xxx is a suffix not beginning with an upper case letter.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Here is an example of an example:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;func ExamplePrintln() {
 Println(&quot;The output of\nthis example.&quot;)
 // Output: The output of
 // this example.
}
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The entire test file is presented as the example when it contains a single example function, at least one other function, type, variable, or constant declaration, and no test or benchmark functions.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
See the documentation of the testing package for more information.&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&quot;footer&quot; style=&quot;color: #666666; font-family: Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 40px; margin-left: 0px; margin-right: 0px; margin-top: 40px; text-align: center;&quot;&gt;
Build version go1.&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bitslabs.blogspot.com/feeds/2908182447669917322/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bitslabs.blogspot.com/2012/04/silver-light-4.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6914906347289349334/posts/default/2908182447669917322'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6914906347289349334/posts/default/2908182447669917322'/><link rel='alternate' type='text/html' href='http://bitslabs.blogspot.com/2012/04/silver-light-4.html' title='Command go'/><author><name>Bits LAB</name><uri>http://www.blogger.com/profile/13420625091230869380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6914906347289349334.post-2620978959893790920</id><published>2012-04-13T00:14:00.000-07:00</published><updated>2012-04-13T00:34:31.733-07:00</updated><title type='text'>Go Programming Language: Installation</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;



&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;a href=&quot;http://3.bp.blogspot.com/-Bel6Iv2YBYA/T4fQZfZ-DlI/AAAAAAAAAEM/1o3AZocv9jo/s1600/logo.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://3.bp.blogspot.com/-Bel6Iv2YBYA/T4fQZfZ-DlI/AAAAAAAAAEM/1o3AZocv9jo/s1600/logo.png&quot; /&gt;&lt;/a&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;&lt;span style=&quot;color: #376092; font-family: Calibri; font-weight: bold;&quot;&gt;The &lt;/span&gt;&lt;span style=&quot;color: #376092; font-family: Calibri; font-weight: bold;&quot;&gt;Go&lt;/span&gt;&lt;span style=&quot;color: #376092; font-family: Calibri; font-weight: bold;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;color: #376092; font-family: Calibri; font-weight: bold;&quot;&gt;Programming&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #376092; font-family: Calibri; font-weight: bold;&quot;&gt;&lt;span style=&quot;font-size: x-large;&quot;&gt;Language&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #376092; font-family: Calibri; font-size: x-small; text-align: center;&quot;&gt;&amp;nbsp;Build version &lt;/span&gt;&lt;span style=&quot;color: #376092; font-family: Calibri; font-size: x-small; text-align: center;&quot;&gt;go1&lt;/span&gt;&lt;/div&gt;
&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #c00000; font-family: Calibri; font-size: 32pt; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #c00000; font-family: Calibri; text-align: center;&quot;&gt;&lt;span style=&quot;font-size: large;&quot;&gt;Installing a binary distribution
of the&amp;nbsp;gc&amp;nbsp;compiler&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;direction: ltr; language: en-IN; margin-bottom: 0pt; margin-left: 0in; margin-top: 4.8pt; mso-line-break-override: none; punctuation-wrap: hanging; text-align: center; text-indent: 0in; unicode-bidi: embed; word-break: normal;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;wide&quot; id=&quot;page&quot; style=&quot;clear: both; color: #222222; font-family: Helvetica, Arial, sans-serif; font-size: 16px; margin-left: auto; margin-right: auto; padding-bottom: 0px; padding-left: 20px; padding-right: 20px; padding-top: 0px; text-align: left; width: auto;&quot;&gt;
&lt;h1 style=&quot;color: #375eab; font-size: 24px; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;



Getting Started&lt;/h1&gt;
&lt;div id=&quot;nav&quot;&gt;
&lt;table class=&quot;unruled&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td class=&quot;first&quot; style=&quot;vertical-align: top;&quot;&gt;
&lt;dl style=&quot;font-size: 14px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
&lt;dt&gt;&lt;a href=&quot;http://golang.org/doc/install#introduction&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Introduction&lt;/a&gt;&lt;/dt&gt;
&lt;dt&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;Download the Go tools&lt;/span&gt;&lt;/dt&gt;
&lt;dt&gt;&lt;a href=&quot;http://golang.org/doc/install#install&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Install the Go tools&lt;/a&gt;&lt;/dt&gt;
&lt;dd style=&quot;margin-bottom: 2px; margin-left: 20px; margin-right: 20px; margin-top: 2px;&quot;&gt;&lt;a href=&quot;http://golang.org/doc/install#windows&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Windows&lt;/a&gt;&lt;/dd&gt;
&lt;dt&gt;&lt;a href=&quot;http://golang.org/doc/install#testing&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Test your installation&lt;/a&gt;&lt;/dt&gt;
&lt;dt&gt;&lt;a href=&quot;http://golang.org/doc/install#next&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;What&#39;s next&lt;/a&gt;&lt;/dt&gt;
&lt;dt&gt;&lt;a href=&quot;http://golang.org/doc/install#community&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Community resources&lt;/a&gt;&lt;/dt&gt;
&lt;/dl&gt;
&lt;/td&gt;&lt;td style=&quot;vertical-align: top;&quot;&gt;
&lt;dl style=&quot;font-size: 14px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;&lt;/dl&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;h2 id=&quot;introduction&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #e0ebf5; background-image: initial; background-origin: initial; clear: right; color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 20px; padding-bottom: 2px; padding-left: 5px; padding-right: 5px; padding-top: 2px;&quot;&gt;



Introduction&lt;/h2&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Go is an open source project with a BSD-style license. There are two official Go compiler toolchains: the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;gc&lt;/code&gt;&amp;nbsp;Go compiler and the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;gccgo&lt;/code&gt;&amp;nbsp;compiler that is part of the GNU C Compiler (GCC).&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;gc&lt;/code&gt;&amp;nbsp;compiler is the more mature and well-tested of the two. This page is about installing a binary distribution of the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;gc&lt;/code&gt;&amp;nbsp;compiler.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
For information about installing the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;gc&lt;/code&gt;&amp;nbsp;compiler from source, see&amp;nbsp;&lt;a href=&quot;http://golang.org/doc/install/source&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Installing Go from source&lt;/a&gt;. For information about installing&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;gccgo&lt;/code&gt;, see&amp;nbsp;&lt;a href=&quot;http://golang.org/doc/install/gccgo&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Setting up and using gccgo&lt;/a&gt;.&lt;/div&gt;
&lt;h2 id=&quot;download&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #e0ebf5; background-image: initial; background-origin: initial; clear: right; color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 20px; padding-bottom: 2px; padding-left: 5px; padding-right: 5px; padding-top: 2px;&quot;&gt;



Download the Go tools&lt;/h2&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Visit the&amp;nbsp;&lt;a href=&quot;http://code.google.com/p/go/downloads&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Go project&#39;s downloads page&lt;/a&gt;&amp;nbsp;and select the binary distribution that matches your operating system and processor architecture.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Official binary distributions are available for the FreeBSD, Linux, Mac OS X (Snow Leopard/Lion), and Windows operating systems and the 32-bit (&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;386&lt;/code&gt;) and 64-bit (&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;amd64&lt;/code&gt;) x86 processor architectures.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
If a binary distribution is not available for your OS/arch combination you may want to try&amp;nbsp;&lt;a href=&quot;http://golang.org/doc/install/source&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;installing from source&lt;/a&gt;&amp;nbsp;or&amp;nbsp;&lt;a href=&quot;http://golang.org/doc/install/gccgo&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;installing gccgo instead of gc&lt;/a&gt;.&lt;/div&gt;
&lt;h2 id=&quot;install&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #e0ebf5; background-image: initial; background-origin: initial; clear: right; color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 20px; padding-bottom: 2px; padding-left: 5px; padding-right: 5px; padding-top: 2px;&quot;&gt;



Install the Go tools&lt;/h2&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The Go binary distributions assume they will be installed in&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;/usr/local/go&lt;/code&gt;&amp;nbsp;(or&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;c:\Go&lt;/code&gt;&amp;nbsp;under Windows), but it is possible to install them in a different location. If you do this, you will need to set the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;GOROOT&lt;/code&gt;&amp;nbsp;environment variable to that directory when using the Go tools.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
For example, if you installed Go to your home directory you should add the following commands to&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;$HOME/.profile&lt;/code&gt;:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;export GOROOT=$HOME/go
export PATH=$PATH:$GOROOT/bin
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Windows users should read the section about&amp;nbsp;&lt;a href=&quot;http://golang.org/doc/install#windows_env&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;setting environment variables under Windows&lt;/a&gt;.&lt;/div&gt;
&lt;h3 id=&quot;freebsd_linux&quot; style=&quot;color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;



Windows&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The Go project provides two installation options for Windows users (besides&amp;nbsp;&lt;a href=&quot;http://golang.org/doc/install/source&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;installing from source&lt;/a&gt;): a zip archive that requires you to set some environment variables and an experimental MSI installer that configures your installation automatically.&lt;/div&gt;
&lt;h4 id=&quot;windows_zip&quot; style=&quot;color: #375eab; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;



Zip archive&lt;/h4&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Extract the&amp;nbsp;&lt;a href=&quot;http://code.google.com/p/go/downloads/list?q=OpSys-Windows+Type%3DArchive&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;zip file&lt;/a&gt;&amp;nbsp;to the directory of your choice (we suggest&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;c:\Go&lt;/code&gt;).&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
If you chose a directory other than&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;c:\Go&lt;/code&gt;, you must set the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;GOROOT&lt;/code&gt;&amp;nbsp;environment variable to your chosen path.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Add the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;bin&lt;/code&gt;&amp;nbsp;subdirectory of your Go root (for example,&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;c:\Go\bin&lt;/code&gt;) to to your&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;PATH&lt;/code&gt;&amp;nbsp;environment variable.&lt;/div&gt;
&lt;h4 id=&quot;windows_msi&quot; style=&quot;color: #375eab; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;



MSI installer (experimental)&lt;/h4&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Open the&amp;nbsp;&lt;a href=&quot;http://code.google.com/p/go/downloads/list?q=OpSys-Windows+Type%3DInstaller&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;MSI file&lt;/a&gt;&amp;nbsp;and follow the prompts to install the Go tools. By default, the installer puts the Go distribution in&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;c:\Go&lt;/code&gt;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The installer should put the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;c:\Go\bin&lt;/code&gt;&amp;nbsp;directory in your&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;PATH&lt;/code&gt;&amp;nbsp;environment variable. You may need to restart any open command prompts for the change to take effect.&lt;/div&gt;
&lt;h4 id=&quot;windows_env&quot; style=&quot;color: #375eab; margin-bottom: 20px; margin-left: 5px; margin-right: 5px; margin-top: 20px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;



Setting environment variables under Windows&lt;/h4&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Under Windows, you may set environment variables through the &quot;Environment Variables&quot; button on the &quot;Advanced&quot; tab of the &quot;System&quot; control panel. Some versions of Windows provide this control panel through the &quot;Advanced System Settings&quot; option inside the &quot;System&quot; control panel.&lt;/div&gt;
&lt;h2 id=&quot;testing&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #e0ebf5; background-image: initial; background-origin: initial; clear: right; color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 20px; padding-bottom: 2px; padding-left: 5px; padding-right: 5px; padding-top: 2px;&quot;&gt;



Test your installation&lt;/h2&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Check that Go is installed correctly by building a simple program, as follows.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Create a file named&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;hello.go&lt;/code&gt;&amp;nbsp;and put the following program in it:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;package main

import &quot;fmt&quot;

func main() {
    fmt.Printf(&quot;hello, world\n&quot;)
}
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Then run it with the&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;go&lt;/code&gt;&amp;nbsp;tool:&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #e9e9e9; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px; border-top-left-radius: 5px; border-top-right-radius: 5px; font-family: Menlo, monospace; font-size: 14px; line-height: 18px; margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;$ go run hello.go
hello, world
&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
If you see the &quot;hello, world&quot; message then your Go installation is working.&lt;/div&gt;
&lt;h2 id=&quot;next&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #e0ebf5; background-image: initial; background-origin: initial; clear: right; color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 20px; padding-bottom: 2px; padding-left: 5px; padding-right: 5px; padding-top: 2px;&quot;&gt;



What&#39;s next&lt;/h2&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Start by taking&amp;nbsp;&lt;a href=&quot;http://code.google.com/p/go-tour/&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;A Tour of Go&lt;/a&gt;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
For more detail about the process of building and testing Go programs read&amp;nbsp;&lt;a href=&quot;http://golang.org/doc/code.html&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;How to Write Go Code&lt;/a&gt;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Build a web application by following the&amp;nbsp;&lt;a href=&quot;http://golang.org/doc/articles/wiki/&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Wiki Tutorial&lt;/a&gt;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Read&amp;nbsp;&lt;a href=&quot;http://golang.org/doc/effective_go.html&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Effective Go&lt;/a&gt;&amp;nbsp;to learn about writing idiomatic Go code.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
For the full story, consult Go&#39;s extensive&amp;nbsp;&lt;a href=&quot;http://golang.org/doc/&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;documentation&lt;/a&gt;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Subscribe to the&amp;nbsp;&lt;a href=&quot;http://groups.google.com/group/golang-announce&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;golang-announce&lt;/a&gt;&amp;nbsp;mailing list to be notified when a new stable version of Go is released.&lt;/div&gt;
&lt;h2 id=&quot;community&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #e0ebf5; background-image: initial; background-origin: initial; clear: right; color: #375eab; font-size: 20px; margin-bottom: 20px; margin-left: 0px; margin-right: 0px; margin-top: 20px; padding-bottom: 2px; padding-left: 5px; padding-right: 5px; padding-top: 2px;&quot;&gt;



Community resources&lt;/h2&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
For real-time help, there may be users or developers on&amp;nbsp;&lt;code style=&quot;font-family: Menlo, monospace; font-size: 14px;&quot;&gt;#go-nuts&lt;/code&gt;&amp;nbsp;on the&amp;nbsp;&lt;a href=&quot;http://freenode.net/&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Freenode&lt;/a&gt;&amp;nbsp;IRC server.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
The official mailing list for discussion of the Go language is&amp;nbsp;&lt;a href=&quot;http://groups.google.com/group/golang-nuts&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Go Nuts&lt;/a&gt;.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 20px; margin-left: 20px; margin-right: 20px; margin-top: 20px;&quot;&gt;
Bugs should be reported using the&amp;nbsp;&lt;a href=&quot;http://code.google.com/p/go/issues/list&quot; style=&quot;color: #375eab; text-decoration: none;&quot;&gt;Go issue tracker&lt;/a&gt;.&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&quot;footer&quot; style=&quot;color: #666666; font-family: Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 40px; margin-left: 0px; margin-right: 0px; margin-top: 40px;&quot;&gt;
Build version go1.&lt;/div&gt;
&lt;div id=&quot;footer&quot; style=&quot;color: #666666; font-family: Helvetica, Arial, sans-serif; font-size: 14px; margin-bottom: 40px; margin-left: 0px; margin-right: 0px; margin-top: 40px;&quot;&gt;
Source :&lt;a href=&quot;http://golang.org/doc/install#windows&quot;&gt;http://golang.org/&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://bitslabs.blogspot.com/feeds/2620978959893790920/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://bitslabs.blogspot.com/2012/04/go-programming-language.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6914906347289349334/posts/default/2620978959893790920'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6914906347289349334/posts/default/2620978959893790920'/><link rel='alternate' type='text/html' href='http://bitslabs.blogspot.com/2012/04/go-programming-language.html' title='Go Programming Language: Installation'/><author><name>Bits LAB</name><uri>http://www.blogger.com/profile/13420625091230869380</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-Bel6Iv2YBYA/T4fQZfZ-DlI/AAAAAAAAAEM/1o3AZocv9jo/s72-c/logo.png" height="72" width="72"/><thr:total>0</thr:total></entry></feed>