mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
Create book_example.go
This commit is contained in:
parent
9891f02d48
commit
6dd8f57f9c
1 changed files with 34 additions and 0 deletions
34
core/book_example.go
Normal file
34
core/book_example.go
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Book struct {
|
||||
title string
|
||||
author string
|
||||
year int
|
||||
}
|
||||
|
||||
func ExampleBooks() {
|
||||
var book1 Book
|
||||
var book2 Book
|
||||
|
||||
book1.title = "The Great Gatsby"
|
||||
book1.author = "F. Scott Fitzgerald"
|
||||
book1.year = 1925
|
||||
|
||||
book2.title = "To Kill a Mockingbird"
|
||||
book2.author = "Harper Lee"
|
||||
book2.year = 1960
|
||||
|
||||
fmt.Println("Book 1:")
|
||||
fmt.Println("Title:", book1.title)
|
||||
fmt.Println("Author:", book1.author)
|
||||
fmt.Println("Year:", book1.year)
|
||||
|
||||
fmt.Println("\nBook 2:")
|
||||
fmt.Println("Title:", book2.title)
|
||||
fmt.Println("Author:", book2.author)
|
||||
fmt.Println("Year:", book2.year)
|
||||
}
|
||||
Loading…
Reference in a new issue