diff --git a/about_allocation.go b/about_allocation.go index 235c0ad..3d662ce 100644 --- a/about_allocation.go +++ b/about_allocation.go @@ -7,7 +7,7 @@ func aboutAllocation() { type person struct { name string - age int + age int } bob := new(person) assert(bob.age == __int__) // it can allocate memory for custom types as well diff --git a/about_arrays.go b/about_arrays.go index 0595d6d..8c635bc 100644 --- a/about_arrays.go +++ b/about_arrays.go @@ -13,7 +13,7 @@ func aboutArrays() { 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[1] == __string__) // albeit slightly askewed diff --git a/about_enumeration.go b/about_enumeration.go index c8acd9c..c6d4c2f 100644 --- a/about_enumeration.go +++ b/about_enumeration.go @@ -12,7 +12,7 @@ func aboutEnumeration() { } 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 } { diff --git a/about_interfaces.go b/about_interfaces.go index 7e3858f..ab364e3 100644 --- a/about_interfaces.go +++ b/about_interfaces.go @@ -2,7 +2,7 @@ package go_koans func aboutInterfaces() { 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 } diff --git a/about_maps.go b/about_maps.go index a2fe643..d2af559 100644 --- a/about_maps.go +++ b/about_maps.go @@ -15,7 +15,7 @@ func aboutMaps() { age, ok = ages["steven"] 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 diff --git a/about_numbers.go b/about_numbers.go index 7d30d56..6f54f2c 100644 --- a/about_numbers.go +++ b/about_numbers.go @@ -1,7 +1,7 @@ package go_koans func aboutNumbers() { - assert(__bool__ == true) // what is truth? + assert(__bool__ == true) // what is truth? assert(__bool__ != false) // in it there is nothing false var i int = __int__ diff --git a/about_pointers.go b/about_pointers.go index 6e7975d..2761254 100644 --- a/about_pointers.go +++ b/about_pointers.go @@ -14,7 +14,7 @@ func aboutPointers() { a := 3 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 } diff --git a/about_slices.go b/about_slices.go index dad1db3..a3fba29 100644 --- a/about_slices.go +++ b/about_slices.go @@ -4,9 +4,9 @@ func aboutSlices() { fruits := []string{"apple", "orange", "mango"} 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 pregnancy_slots := []string{"baby", "baby", "lemon"} diff --git a/about_strings.go b/about_strings.go index dc0bcdb..5a2a9b5 100644 --- a/about_strings.go +++ b/about_strings.go @@ -3,18 +3,18 @@ package go_koans import "fmt" func aboutStrings() { - assert("a" + __string__ == "abc") // string concatenation need not be difficult - assert(len("abc") == __int__) // and bounds are thoroughly checked + assert("a"+__string__ == "abc") // string concatenation need not be difficult + assert(len("abc") == __int__) // and bounds are thoroughly checked assert("abc"[0] == __byte__) // their contents are reminiscent of C - assert("smith"[2:] == __string__) // slicing may omit the end point - assert("smith"[:4] == __string__) // or the beginning + assert("smith"[2:] == __string__) // slicing may omit the end point + assert("smith"[:4] == __string__) // or the beginning 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__) // i suppose maybe this could be useful.. someday + assert("smith" < __string__) // i suppose maybe this could be useful.. someday bytes := []byte{'a', 'b', 'c'} 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(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 %q", "world") == __string__) // although it can be done easilier + 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("your balance: %d and %0.2f", 3, 4.5589) == __string__) // "the root of all evil" is actually a misquotation, by the way } diff --git a/about_structs.go b/about_structs.go index c971bde..5298102 100644 --- a/about_structs.go +++ b/about_structs.go @@ -3,17 +3,17 @@ package go_koans func aboutStructs() { var bob struct { name string - age int + age int } bob.name = "bob" bob.age = 30 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 { name string - age int + age int } var john person diff --git a/setup_koans_test.go b/setup_koans_test.go index 72eff07..6b2e132 100644 --- a/setup_koans_test.go +++ b/setup_koans_test.go @@ -1,13 +1,13 @@ package go_koans import ( - "testing" - "os" "fmt" - "runtime" "io/ioutil" + "os" "path" + "runtime" "strings" + "testing" ) var __string__ string = "impossibly lame value"