mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 05:11:49 +08:00
fix: coding style and file format for chapter 10.
This commit is contained in:
@@ -1,29 +1,30 @@
|
||||
// magic.go
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
type Base struct{}
|
||||
|
||||
func (Base) Magic() { fmt.Print("base magic ") }
|
||||
|
||||
func (self Base) MoreMagic() {
|
||||
self.Magic()
|
||||
self.Magic()
|
||||
}
|
||||
|
||||
type Voodoo struct {
|
||||
Base
|
||||
}
|
||||
|
||||
func (Voodoo) Magic() { fmt.Println("voodoo magic") }
|
||||
|
||||
func main() {
|
||||
v := new(Voodoo)
|
||||
v.Magic()
|
||||
v.MoreMagic()
|
||||
}
|
||||
/* Output:
|
||||
voodoo magic
|
||||
base magic base magic
|
||||
*/
|
||||
// magic.go
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
type Base struct{}
|
||||
|
||||
func (Base) Magic() { fmt.Print("base magic ") }
|
||||
|
||||
func (self Base) MoreMagic() {
|
||||
self.Magic()
|
||||
self.Magic()
|
||||
}
|
||||
|
||||
type Voodoo struct {
|
||||
Base
|
||||
}
|
||||
|
||||
func (Voodoo) Magic() { fmt.Println("voodoo magic") }
|
||||
|
||||
func main() {
|
||||
v := new(Voodoo)
|
||||
v.Magic()
|
||||
v.MoreMagic()
|
||||
}
|
||||
|
||||
/* Output:
|
||||
voodoo magic
|
||||
base magic base magic
|
||||
*/
|
||||
|
Reference in New Issue
Block a user