From 6dd8f57f9cb06f8816c3074614c404f33fdc0c01 Mon Sep 17 00:00:00 2001 From: "M.Mohamed Fouzhan" Date: Fri, 18 Oct 2024 15:17:39 +0530 Subject: [PATCH] Create book_example.go --- core/book_example.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 core/book_example.go diff --git a/core/book_example.go b/core/book_example.go new file mode 100644 index 0000000000..24eac7e434 --- /dev/null +++ b/core/book_example.go @@ -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) +}