Introduction
In this challenge, you are a software developer creating a digital catalog for a local library. The librarian needs a system to track book information efficiently using Go's variable capabilities. You will create a Go program to declare and initialize variables representing a book's title, page count, and availability status, and then print out these variables.
Craft Book Inventory Variables
You are a software developer creating a digital catalog for a local library. The librarian needs a system to track book information efficiently using Go's variable capabilities.
Tasks
- Create a Go program named
book_inventory.goin the~/projectdirectory - Declare and initialize three variables representing book details:
- A variable for the book's title (string type)
- A variable for the book's page count (integer type)
- A variable for the book's availability status (boolean type)
- Print out these variables using
fmt.Println()
Requirements
- Use the file
~/project/book_inventory.go - Declare variables using Go's type inference (
:=) or explicit type declaration - The book title should be a non-empty string
- The page count should be a positive integer
- The availability status should be a boolean value
- Use
fmt.Println()to display the variables
Examples
cd ~/project
go run book_inventory.go
Example output might look like:
The Great Gatsby
224
true
Hints
- Remember that Go uses
:=for short variable declaration inside functions - You can use
varkeyword for explicit type declaration if preferred - Make sure to import the
fmtpackage for printing - Choose meaningful variable names that describe the book's attributes
Summary
In summary, this challenge requires you to create a Go program that declares and initializes variables representing a book's title, page count, and availability status, and then prints out these variables. The goal is to demonstrate your understanding of Go's variable capabilities in the context of a book inventory management system.



