formatting

This commit is contained in:
Mark McGranaghan 2012-09-22 14:17:22 -04:00
parent 5382f4fa9c
commit 5b7c5e7f3f
4 changed files with 23 additions and 23 deletions

View File

@ -3,7 +3,7 @@ package main // `for` is Go's only looping construct. Below a
import "fmt" import "fmt"
func main() { func main() {
i := 1 // We initialize `i` with `1` and loop until it's 10. i := 1 // Initialize `i` with `1` and loop until it's 10.
for i <= 3 { for i <= 3 {
fmt.Print(i) fmt.Print(i)
i = i + 1 i = i + 1

View File

@ -4,8 +4,8 @@ import "fmt"
func main() { func main() {
fmt.Print("7 is ") fmt.Print("7 is ")
if 7 % 2 == 0 { // If/else is straightford. Note that there are no if 7 % 2 == 0 { // If/else is straight-forward. Note that there are no
fmt.Println("even") // enclosing parenthesis around the condition. fmt.Println("even") // enclosing parentheses around the condition.
} else { // Also, there is no ternary operator (`?`) in Go. } else { // Also, there is no ternary operator (`?`) in Go.
fmt.Println("odd") fmt.Println("odd")
} }

View File

@ -1,6 +1,6 @@
package main // We can use channels to synchronize execution package main // We can use channels to synchronize execution
// accross goroutings. Here's an example of waiting // accross goroutines. Here's an example of waiting
import "fmt" // for another gorouting to finish. import "fmt" // for another goroutine to finish.
import "time" import "time"
func worker(done chan<- bool) { // The `done` channel will be used for func worker(done chan<- bool) { // The `done` channel will be used for

View File

@ -16,7 +16,7 @@ func main() {
out := os.Stdout out := os.Stdout
for { // If succesful, each `ReadLine` returns bytes and a for { // If succesful, each `ReadLine` returns bytes and a
inBytes, pfx, err := in.ReadLine() // boolean indicating if don't have the whole line. inBytes, pfx, err := in.ReadLine() // boolean indicating if don't have the whole line yet.
if err == io.EOF { // The `EOF` error is expected when we reach the end if err == io.EOF { // The `EOF` error is expected when we reach the end
return // of the input, so exit gracefully in that case. return // of the input, so exit gracefully in that case.