Appendix A. Answers
Appendix A. Chapter 1
Whitespace is the space between characters made up of space, tab, and newline characters.
A comment is a section of code ignored by the compiler that can be used as a note for anyone reading the code. The two types of comments are
//(which goes to the end of the line) and/* */.The files in the
fmtpackage would begin withpackage fmt.In order to use the
Exitfunction from theospackage, you would need to import theospackage:import "os"and then invoke it with.:os.Exit().Modifying the program to print with your name:
packagemainimport"fmt"funcmain(){fmt.Println("Hello, my name is Caleb")}
Appendix A. Chapter 2
Integers are stored on a computer by using a base-2, binary number system.
The largest eight-digit number in binary is 255.
Program that computes 32,132 × 42,452 and prints it to terminal:
packagemainimport"fmt"funcmain(){fmt.Println(32132*42452)}A string is a sequence of characters. You can find the length of a string using the
lenfunction (len("a string")).The value of the expression is
true.
Appendix A. Chapter 3
Two ways to create a new variable are:
var x = 5orx := 5.The value of
xafter running the equation is6.Scope is the range of places a variable can be used. Scope in Go is determined lexically using blocks, so look for the nearest curly braces.
Unlike a variable, the value of a constant is determined at compile time and cannot change throughout the lifetime of a program.
Program ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access