定义一个结构体 type Book struct {title stringauth string } 结构体使用 package mainimport "fmt"//定义一个结构体 type Book struct {title stringauth string }func main() {var book1 Bookbook1.title = "Golang"book1.auth = "zhang3"fmt.Println("%v\n",book1) } 结构体传参 package mainimport "fmt"//定义一个结构体 type Book struct {title stringauth string }func changeBook(book Book) {//传递一个book的副本book.auth = "666" }func changeBook3(book *Book) {//指针传递book.auth = "777"}func main() {var book1 Bookbook1.title = "Golang"book1.auth = "zhang3"fmt.Println("%v\n",book1)//副本传递是不会改变结构体的值changeBook(book1)fmt.Println("副本传递",book1)//指针传递changeBook3(&book1)fmt.Println("指针传递",book1) }