Create book_example.go

This commit is contained in:
M.Mohamed Fouzhan 2024-10-18 15:17:39 +05:30 committed by GitHub
parent 9891f02d48
commit 6dd8f57f9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

34
core/book_example.go Normal file
View 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)
}