Run "go fmt" on all .go files

This commit is contained in:
John Gosset
2014-12-09 09:04:26 -05:00
parent 19cbebee5e
commit ac49ca7392
20 changed files with 380 additions and 379 deletions

View File

@@ -1,48 +1,48 @@
package go_koans
func aboutInterfaces() {
bob := new(human) // bob is a kind of *human
rspec := new(program) // rspec is a kind of *program
bob := new(human) // bob is a kind of *human
rspec := new(program) // rspec is a kind of *program
assert(runner(bob) == __runner__) // conformed interfaces need not be declared, they are inferred
assert(runner(bob) == __runner__) // conformed interfaces need not be declared, they are inferred
assert(bob.milesCompleted == 0)
assert(rspec.executionCount == 0)
assert(bob.milesCompleted == 0)
assert(rspec.executionCount == 0)
runTwice(bob) // bob fits the profile for a 'runner'
runTwice(rspec) // rspec also fits the profile for a 'runner'
runTwice(bob) // bob fits the profile for a 'runner'
runTwice(rspec) // rspec also fits the profile for a 'runner'
assert(bob.milesCompleted == __int__) // bob is affected by running in his own unique way (probably fatigue)
assert(rspec.executionCount == __int__) // rspec can run completely differently than bob, thanks to interfaces
assert(bob.milesCompleted == __int__) // bob is affected by running in his own unique way (probably fatigue)
assert(rspec.executionCount == __int__) // rspec can run completely differently than bob, thanks to interfaces
}
// abstract interface and function that requires it
type runner interface {
run()
run()
}
func runTwice(r runner) {
r.run()
r.run()
r.run()
r.run()
}
// concrete type implementing the interface
type human struct {
milesCompleted int
milesCompleted int
}
func (self *human) run() {
self.milesCompleted++
self.milesCompleted++
}
// another concrete type implementing the interface
type program struct {
executionCount int
executionCount int
}
func (self *program) run() {
self.executionCount++
self.executionCount++
}