mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 02:16:48 +08:00
update book code
This commit is contained in:
14
eBook/examples/chapter_10/use_person2.go
Normal file
14
eBook/examples/chapter_10/use_person2.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"./person"
|
||||
)
|
||||
|
||||
func main() {
|
||||
p := new(person.Person)
|
||||
// error: p.firstName undefined (cannot refer to unexported field or method firstName)
|
||||
// p.firstName = "Eric"
|
||||
p.SetFirstName("Eric")
|
||||
fmt.Println(p.FirstName()) // Output: Eric
|
||||
}
|
Reference in New Issue
Block a user