mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 01:21:38 +08:00
fix: coding style and file format for all example.
This commit is contained in:
@@ -1,34 +1,34 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
type innerS struct {
|
||||
in1 int
|
||||
in2 int
|
||||
}
|
||||
|
||||
type outerS struct {
|
||||
b int
|
||||
c float32
|
||||
int // anonymous field
|
||||
innerS // anonymous field
|
||||
}
|
||||
|
||||
func main() {
|
||||
outer := new(outerS)
|
||||
outer.b = 6
|
||||
outer.c = 7.5
|
||||
outer.int = 60
|
||||
outer.in1 = 5
|
||||
outer.in2 = 10
|
||||
|
||||
fmt.Printf("outer.b is: %d\n", outer.b)
|
||||
fmt.Printf("outer.c is: %f\n", outer.c)
|
||||
fmt.Printf("outer.int is: %d\n", outer.int)
|
||||
fmt.Printf("outer.in1 is: %d\n", outer.in1)
|
||||
fmt.Printf("outer.in2 is: %d\n", outer.in2)
|
||||
// with a struct-literal:
|
||||
outer2 := outerS{6, 7.5, 60, innerS{5, 10}}
|
||||
fmt.Println("outer2 is: ", outer2)
|
||||
|
||||
}
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
type innerS struct {
|
||||
in1 int
|
||||
in2 int
|
||||
}
|
||||
|
||||
type outerS struct {
|
||||
b int
|
||||
c float32
|
||||
int // anonymous field
|
||||
innerS // anonymous field
|
||||
}
|
||||
|
||||
func main() {
|
||||
outer := new(outerS)
|
||||
outer.b = 6
|
||||
outer.c = 7.5
|
||||
outer.int = 60
|
||||
outer.in1 = 5
|
||||
outer.in2 = 10
|
||||
|
||||
fmt.Printf("outer.b is: %d\n", outer.b)
|
||||
fmt.Printf("outer.c is: %f\n", outer.c)
|
||||
fmt.Printf("outer.int is: %d\n", outer.int)
|
||||
fmt.Printf("outer.in1 is: %d\n", outer.in1)
|
||||
fmt.Printf("outer.in2 is: %d\n", outer.in2)
|
||||
// with a struct-literal:
|
||||
outer2 := outerS{6, 7.5, 60, innerS{5, 10}}
|
||||
fmt.Println("outer2 is: ", outer2)
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user