Skip to content

Commit ac49ca7

Browse files
committed
Run "go fmt" on all .go files
1 parent 19cbebe commit ac49ca7

20 files changed

+388
-387
lines changed

about_allocation.go

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
package go_koans
22

33
func aboutAllocation() {
4-
a := new(int)
5-
*a = 3
6-
assert(*a == __int__) // new() creates a pointer to the given type, like malloc() in C
4+
a := new(int)
5+
*a = 3
6+
assert(*a == __int__) // new() creates a pointer to the given type, like malloc() in C
77

8-
type person struct {
9-
name string
10-
age int
11-
}
12-
bob := new(person)
13-
assert(bob.age == __int__) // it can allocate memory for custom types as well
8+
type person struct {
9+
name string
10+
age int
11+
}
12+
bob := new(person)
13+
assert(bob.age == __int__) // it can allocate memory for custom types as well
1414

15-
slice := make([]int, 3)
16-
assert(len(slice) == __int__) // make() creates slices of a given length
15+
slice := make([]int, 3)
16+
assert(len(slice) == __int__) // make() creates slices of a given length
1717

18-
slice = make([]int, 3, __positive_int__) // but can also take an optional capacity
19-
assert(cap(slice) == 20)
18+
slice = make([]int, 3, __positive_int__) // but can also take an optional capacity
19+
assert(cap(slice) == 20)
2020

21-
m := make(map[int]string)
22-
assert(len(m) == __int__) // make() also creates maps
21+
m := make(map[int]string)
22+
assert(len(m) == __int__) // make() also creates maps
2323
}

about_anonymous_functions.go

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
package go_koans
22

33
func aboutAnonymousFunctions() {
4-
{
5-
i := 1
6-
increment := func() {
7-
i++
8-
}
9-
increment()
4+
{
5+
i := 1
6+
increment := func() {
7+
i++
8+
}
9+
increment()
1010

11-
assert(i == __int__) // closures function in an obvious way
12-
}
11+
assert(i == __int__) // closures function in an obvious way
12+
}
1313

14-
{
15-
i := 1
16-
increment := func(x int) {
17-
x++
18-
}
19-
increment(i)
14+
{
15+
i := 1
16+
increment := func(x int) {
17+
x++
18+
}
19+
increment(i)
2020

21-
assert(i == __int__) // although anonymous functions need not always be closures
22-
}
21+
assert(i == __int__) // although anonymous functions need not always be closures
22+
}
2323

24-
{
25-
double := func(x int) int { return x * 2 }
24+
{
25+
double := func(x int) int { return x * 2 }
2626

27-
assert(double(3) == __int__) // they can do anything our hearts desire
28-
}
27+
assert(double(3) == __int__) // they can do anything our hearts desire
28+
}
2929
}

about_arrays.go

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
package go_koans
22

33
func aboutArrays() {
4-
fruits := [4]string{"apple", "orange", "mango"}
4+
fruits := [4]string{"apple", "orange", "mango"}
55

6-
assert(fruits[0] == __string__) // indexes begin at 0
7-
assert(fruits[1] == __string__) // one is indeed the loneliest number
8-
assert(fruits[2] == __string__) // it takes two to ...tango?
9-
assert(fruits[3] == __string__) // there is no spoon, only an empty value
6+
assert(fruits[0] == __string__) // indexes begin at 0
7+
assert(fruits[1] == __string__) // one is indeed the loneliest number
8+
assert(fruits[2] == __string__) // it takes two to ...tango?
9+
assert(fruits[3] == __string__) // there is no spoon, only an empty value
1010

11-
assert(len(fruits) == __int__) // the length is what the length is
12-
assert(cap(fruits) == __int__) // it can hold no more
11+
assert(len(fruits) == __int__) // the length is what the length is
12+
assert(cap(fruits) == __int__) // it can hold no more
1313

14-
assert(fruits == [4]string{}) // comparing arrays is not like comparing apples and oranges
14+
assert(fruits == [4]string{}) // comparing arrays is not like comparing apples and oranges
1515

16-
tasty_fruits := fruits[1:3] // defining oneself as a variation of another
17-
assert(tasty_fruits[0] == __string__) // slices of arrays share some data
18-
assert(tasty_fruits[1] == __string__) // albeit slightly askewed
16+
tasty_fruits := fruits[1:3] // defining oneself as a variation of another
17+
assert(tasty_fruits[0] == __string__) // slices of arrays share some data
18+
assert(tasty_fruits[1] == __string__) // albeit slightly askewed
1919

20-
assert(len(tasty_fruits) == __int__) // its length is manifest
21-
assert(cap(tasty_fruits) == __int__) // but its capacity is surprising!
20+
assert(len(tasty_fruits) == __int__) // its length is manifest
21+
assert(cap(tasty_fruits) == __int__) // but its capacity is surprising!
2222

23-
tasty_fruits[0] = "lemon" // are their shared roots truly identical?
23+
tasty_fruits[0] = "lemon" // are their shared roots truly identical?
2424

25-
assert(fruits[0] == __string__) // has this element remained the same?
26-
assert(fruits[1] == __string__) // how about the second?
27-
assert(fruits[2] == __string__) // surely one of these must have changed
28-
assert(fruits[3] == __string__) // but who can know these things
25+
assert(fruits[0] == __string__) // has this element remained the same?
26+
assert(fruits[1] == __string__) // how about the second?
27+
assert(fruits[2] == __string__) // surely one of these must have changed
28+
assert(fruits[3] == __string__) // but who can know these things
2929

30-
veggies := [...]string{"carrot", "pea"}
30+
veggies := [...]string{"carrot", "pea"}
3131

32-
assert(len(veggies) == __int__) // array literals need not repeat an obvious length
32+
assert(len(veggies) == __int__) // array literals need not repeat an obvious length
3333
}

about_basics.go

+21-21
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
package go_koans
22

33
func aboutBasics() {
4-
assert(__bool__ == true) // what is truth?
5-
assert(__bool__ != false) // in it there is nothing false
4+
assert(__bool__ == true) // what is truth?
5+
assert(__bool__ != false) // in it there is nothing false
66

7-
var i int = __int__
8-
assert(i == 1.0000000000000000000000000000000000000) // precision is in the eye of the beholder
7+
var i int = __int__
8+
assert(i == 1.0000000000000000000000000000000000000) // precision is in the eye of the beholder
99

10-
assert(5 % 2 == __int__)
11-
assert(5 * 2 == __int__)
12-
assert(5 ^ 2 == __int__)
10+
assert(5%2 == __int__)
11+
assert(5*2 == __int__)
12+
assert(5^2 == __int__)
1313

14-
var x int
15-
assert(x == __int__) // zero values are valued in Go
14+
var x int
15+
assert(x == __int__) // zero values are valued in Go
1616

17-
var f float32
18-
assert(f == __float32__) // for types of all types
17+
var f float32
18+
assert(f == __float32__) // for types of all types
1919

20-
var s string
21-
assert(s == __string__) // both typical or atypical types
20+
var s string
21+
assert(s == __string__) // both typical or atypical types
2222

23-
var c struct {
24-
x int
25-
f float32
26-
s string
27-
}
28-
assert(c.x == __int__) // and types within composite types
29-
assert(c.f == __float32__) // which match the other types
30-
assert(c.s == __string__) // in a typical way
23+
var c struct {
24+
x int
25+
f float32
26+
s string
27+
}
28+
assert(c.x == __int__) // and types within composite types
29+
assert(c.f == __float32__) // which match the other types
30+
assert(c.s == __string__) // in a typical way
3131
}

about_channels.go

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
package go_koans
22

33
func aboutChannels() {
4-
ch := make(chan string, 2)
4+
ch := make(chan string, 2)
55

6-
assert(len(ch) == __int__) // channels are like buffers
6+
assert(len(ch) == __int__) // channels are like buffers
77

8-
ch <- "foo" // i mean, "metaphors are like similes"
8+
ch <- "foo" // i mean, "metaphors are like similes"
99

10-
assert(len(ch) == __int__) // they can be queried for queued items
10+
assert(len(ch) == __int__) // they can be queried for queued items
1111

12-
assert(<-ch == __string__) // items can be popped out of them
12+
assert(<-ch == __string__) // items can be popped out of them
1313

14-
assert(len(ch) == __int__) // and len() always reflects the "current" queue status
14+
assert(len(ch) == __int__) // and len() always reflects the "current" queue status
1515

16-
// the 'go' keyword runs a function-call in a new "goroutine"
17-
// which executes "concurrently" with the calling "goroutine"
18-
go func() {
19-
// your code goes here
20-
}()
16+
// the 'go' keyword runs a function-call in a new "goroutine"
17+
// which executes "concurrently" with the calling "goroutine"
18+
go func() {
19+
// your code goes here
20+
}()
2121

22-
assert(__delete_me__) // we'll need to make room for the queue, or suffer deadlocks
22+
assert(__delete_me__) // we'll need to make room for the queue, or suffer deadlocks
2323

24-
ch <- "bar" // this send will succeed
25-
ch <- "quux" // there's enough room for this send too
26-
ch <- "extra" // but the buffer only has two slots
24+
ch <- "bar" // this send will succeed
25+
ch <- "quux" // there's enough room for this send too
26+
ch <- "extra" // but the buffer only has two slots
2727
}

about_common_interfaces.go

+19-19
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,30 @@ package go_koans
33
import "bytes"
44

55
func aboutCommonInterfaces() {
6-
{
7-
in := new(bytes.Buffer)
8-
in.WriteString("hello world")
6+
{
7+
in := new(bytes.Buffer)
8+
in.WriteString("hello world")
99

10-
out := new(bytes.Buffer)
10+
out := new(bytes.Buffer)
1111

12-
/*
13-
Your code goes here.
14-
Hint, use these resources:
12+
/*
13+
Your code goes here.
14+
Hint, use these resources:
1515
16-
$ godoc -http=:8080
17-
$ open http://localhost:8080/pkg/io/
18-
$ open http://localhost:8080/pkg/bytes/
19-
*/
16+
$ godoc -http=:8080
17+
$ open http://localhost:8080/pkg/io/
18+
$ open http://localhost:8080/pkg/bytes/
19+
*/
2020

21-
assert(out.String() == "hello world") // get data from the io.Reader to the io.Writer
22-
}
21+
assert(out.String() == "hello world") // get data from the io.Reader to the io.Writer
22+
}
2323

24-
{
25-
in := new(bytes.Buffer)
26-
in.WriteString("hello world")
24+
{
25+
in := new(bytes.Buffer)
26+
in.WriteString("hello world")
2727

28-
out := new(bytes.Buffer)
28+
out := new(bytes.Buffer)
2929

30-
assert(out.String() == "hello") // duplicate only a portion of the io.Reader
31-
}
30+
assert(out.String() == "hello") // duplicate only a portion of the io.Reader
31+
}
3232
}

about_concurrency.go

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
package go_koans
22

33
func isPrimeNumber(possiblePrime int) bool {
4-
for underPrime := 2; underPrime < possiblePrime; underPrime++ {
5-
if possiblePrime % underPrime == 0 {
6-
return false
7-
}
8-
}
9-
return true
4+
for underPrime := 2; underPrime < possiblePrime; underPrime++ {
5+
if possiblePrime%underPrime == 0 {
6+
return false
7+
}
8+
}
9+
return true
1010
}
1111

1212
func findPrimeNumbers(channel chan int) {
13-
for i := 2; /* infinite loop */ ; i++ {
14-
// your code goes here
13+
for i := 2; ; /* infinite loop */ i++ {
14+
// your code goes here
1515

16-
assert(i < 100) // i is afraid of heights
17-
}
16+
assert(i < 100) // i is afraid of heights
17+
}
1818
}
1919

2020
func aboutConcurrency() {
21-
ch := make(chan int)
21+
ch := make(chan int)
2222

23-
assert(__delete_me__) // concurrency can be almost trivial
24-
// your code goes here
23+
assert(__delete_me__) // concurrency can be almost trivial
24+
// your code goes here
2525

26-
assert(<-ch == 2)
27-
assert(<-ch == 3)
28-
assert(<-ch == 5)
29-
assert(<-ch == 7)
30-
assert(<-ch == 11)
26+
assert(<-ch == 2)
27+
assert(<-ch == 3)
28+
assert(<-ch == 5)
29+
assert(<-ch == 7)
30+
assert(<-ch == 11)
3131
}

0 commit comments

Comments
 (0)