gofmt -l -w -tabs=false -tabwidth=2 *

This commit is contained in:
Steven Degutis
2012-03-16 10:43:33 -05:00
parent 0d62c739d6
commit ce4ffc8a43
11 changed files with 23 additions and 23 deletions

View File

@@ -7,7 +7,7 @@ func aboutAllocation() {
type person struct { type person struct {
name string name string
age int age int
} }
bob := new(person) bob := new(person)
assert(bob.age == __int__) // it can allocate memory for custom types as well assert(bob.age == __int__) // it can allocate memory for custom types as well

View File

@@ -13,7 +13,7 @@ func aboutArrays() {
assert(fruits == [4]string{}) // comparing arrays is not like comparing apples and oranges assert(fruits == [4]string{}) // comparing arrays is not like comparing apples and oranges
tasty_fruits := fruits[1:3] // defining oneself as a variation of another tasty_fruits := fruits[1:3] // defining oneself as a variation of another
assert(tasty_fruits[0] == __string__) // slices of arrays share some data assert(tasty_fruits[0] == __string__) // slices of arrays share some data
assert(tasty_fruits[1] == __string__) // albeit slightly askewed assert(tasty_fruits[1] == __string__) // albeit slightly askewed

View File

@@ -12,7 +12,7 @@ func aboutEnumeration() {
} }
assert(concatenated == __string__) // for loops have a modern variation assert(concatenated == __string__) // for loops have a modern variation
assert(total == __int__) // which offers both a value and an index assert(total == __int__) // which offers both a value and an index
} }
{ {

View File

@@ -2,7 +2,7 @@ package go_koans
func aboutInterfaces() { func aboutInterfaces() {
mspaint := &program{3} // mspaint is a kind of *program, which is a valid 'runner' mspaint := &program{3} // mspaint is a kind of *program, which is a valid 'runner'
runOnce(mspaint) // runOnce takes an abstract 'runner' type runOnce(mspaint) // runOnce takes an abstract 'runner' type
assert(mspaint.runTimes == __int__) // conformed interfaces need not be declared, they are inferred assert(mspaint.runTimes == __int__) // conformed interfaces need not be declared, they are inferred
} }

View File

@@ -15,7 +15,7 @@ func aboutMaps() {
age, ok = ages["steven"] age, ok = ages["steven"]
assert(age == __int__) // the zero value is used when absent assert(age == __int__) // the zero value is used when absent
assert(__bool__) // though there are better ways to check for presence assert(__bool__) // though there are better ways to check for presence
assert(len(ages) == __int__) // length is based on keys assert(len(ages) == __int__) // length is based on keys

View File

@@ -1,7 +1,7 @@
package go_koans package go_koans
func aboutNumbers() { func aboutNumbers() {
assert(__bool__ == true) // what is truth? assert(__bool__ == true) // what is truth?
assert(__bool__ != false) // in it there is nothing false assert(__bool__ != false) // in it there is nothing false
var i int = __int__ var i int = __int__

View File

@@ -14,7 +14,7 @@ func aboutPointers() {
a := 3 a := 3
b := &a // 'b' is the address of 'a' b := &a // 'b' is the address of 'a'
*b = *b + 2 // de-referencing 'b' means acting like a mutable copy of 'a' *b = *b + 2 // de-referencing 'b' means acting like a mutable copy of 'a'
assert(a == __int__) // pointers seem complicated at first but are actually simple assert(a == __int__) // pointers seem complicated at first but are actually simple
} }

View File

@@ -4,9 +4,9 @@ func aboutSlices() {
fruits := []string{"apple", "orange", "mango"} fruits := []string{"apple", "orange", "mango"}
assert(fruits[0] == __string__) // slices seem like arrays assert(fruits[0] == __string__) // slices seem like arrays
assert(len(fruits) == __int__) // in nearly all respects assert(len(fruits) == __int__) // in nearly all respects
tasty_fruits := fruits[1:3] // we can even slice slices tasty_fruits := fruits[1:3] // we can even slice slices
assert(tasty_fruits[0] == __string__) // slices of slices also share the underlying data assert(tasty_fruits[0] == __string__) // slices of slices also share the underlying data
pregnancy_slots := []string{"baby", "baby", "lemon"} pregnancy_slots := []string{"baby", "baby", "lemon"}

View File

@@ -3,18 +3,18 @@ package go_koans
import "fmt" import "fmt"
func aboutStrings() { func aboutStrings() {
assert("a" + __string__ == "abc") // string concatenation need not be difficult assert("a"+__string__ == "abc") // string concatenation need not be difficult
assert(len("abc") == __int__) // and bounds are thoroughly checked assert(len("abc") == __int__) // and bounds are thoroughly checked
assert("abc"[0] == __byte__) // their contents are reminiscent of C assert("abc"[0] == __byte__) // their contents are reminiscent of C
assert("smith"[2:] == __string__) // slicing may omit the end point assert("smith"[2:] == __string__) // slicing may omit the end point
assert("smith"[:4] == __string__) // or the beginning assert("smith"[:4] == __string__) // or the beginning
assert("smith"[2:4] == __string__) // or neither assert("smith"[2:4] == __string__) // or neither
assert("smith"[:] == __string__) // or both assert("smith"[:] == __string__) // or both
assert("smith" == __string__) // they can be compared directly assert("smith" == __string__) // they can be compared directly
assert("smith" < __string__) // i suppose maybe this could be useful.. someday assert("smith" < __string__) // i suppose maybe this could be useful.. someday
bytes := []byte{'a', 'b', 'c'} bytes := []byte{'a', 'b', 'c'}
assert(string(bytes) == __string__) // strings can be created from byte-slices assert(string(bytes) == __string__) // strings can be created from byte-slices
@@ -23,8 +23,8 @@ func aboutStrings() {
assert(string(bytes) == __string__) // byte-slices can be mutated, although strings cannot assert(string(bytes) == __string__) // byte-slices can be mutated, although strings cannot
assert(fmt.Sprintf("hello %s", __string__) == "hello world") // our old friend sprintf returns assert(fmt.Sprintf("hello %s", __string__) == "hello world") // our old friend sprintf returns
assert(fmt.Sprintf("hello \"%s\"", "world") == __string__) // quoting is familiar assert(fmt.Sprintf("hello \"%s\"", "world") == __string__) // quoting is familiar
assert(fmt.Sprintf("hello %q", "world") == __string__) // although it can be done easilier assert(fmt.Sprintf("hello %q", "world") == __string__) // although it can be done easilier
assert(fmt.Sprintf("your balance: %d and %0.2f", 3, 4.5589) == __string__) // "the root of all evil" is actually a misquotation, by the way assert(fmt.Sprintf("your balance: %d and %0.2f", 3, 4.5589) == __string__) // "the root of all evil" is actually a misquotation, by the way
} }

View File

@@ -3,17 +3,17 @@ package go_koans
func aboutStructs() { func aboutStructs() {
var bob struct { var bob struct {
name string name string
age int age int
} }
bob.name = "bob" bob.name = "bob"
bob.age = 30 bob.age = 30
assert(bob.name == __string__) // structs are collections of named variables assert(bob.name == __string__) // structs are collections of named variables
assert(bob.age == __int__) // each field has both setter and getter behavior assert(bob.age == __int__) // each field has both setter and getter behavior
type person struct { type person struct {
name string name string
age int age int
} }
var john person var john person

View File

@@ -1,13 +1,13 @@
package go_koans package go_koans
import ( import (
"testing"
"os"
"fmt" "fmt"
"runtime"
"io/ioutil" "io/ioutil"
"os"
"path" "path"
"runtime"
"strings" "strings"
"testing"
) )
var __string__ string = "impossibly lame value" var __string__ string = "impossibly lame value"