2018-12-05 15:02:03 +03:00
|
|
|
// Copyright © 2018 Inanc Gumus
|
|
|
|
// Learn Go Programming Course
|
|
|
|
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
|
|
|
|
//
|
2019-10-30 19:34:44 +03:00
|
|
|
// For more tutorials : https://learngoprogramming.com
|
|
|
|
// In-person training : https://www.linkedin.com/in/inancgumus/
|
|
|
|
// Follow me on twitter: https://twitter.com/inancgumus
|
2018-12-05 15:02:03 +03:00
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
// ---------------------------------------------------------
|
2018-12-05 19:48:28 +03:00
|
|
|
// EXERCISE: Hipster's Love Bookstore Search Engine
|
2018-12-05 15:02:03 +03:00
|
|
|
//
|
2018-12-05 19:48:28 +03:00
|
|
|
// Your goal is to allow people to search for books.
|
2018-12-05 15:02:03 +03:00
|
|
|
//
|
2018-12-05 19:48:28 +03:00
|
|
|
// 1. Create an array with the following book titles:
|
2018-12-05 15:02:03 +03:00
|
|
|
// Kafka's Revenge
|
|
|
|
// Stay Golden
|
|
|
|
// Everythingship
|
|
|
|
// Kafka's Revenge 2nd Edition
|
|
|
|
//
|
|
|
|
// 2. Get the search query from the command-line argument
|
|
|
|
//
|
|
|
|
// 3. Search for the books in the books array
|
|
|
|
//
|
2018-12-05 19:48:28 +03:00
|
|
|
// 4. When the program finds the book, print it.
|
2018-12-05 15:02:03 +03:00
|
|
|
// 5. Otherwise, print that the book doesn't exist.
|
|
|
|
//
|
|
|
|
// 6. Handle the errors.
|
|
|
|
//
|
|
|
|
// RESTRICTION:
|
|
|
|
// + The search should be case insensitive.
|
|
|
|
//
|
|
|
|
// EXPECTED OUTPUT
|
|
|
|
// go run main.go
|
|
|
|
// Tell me a book title
|
|
|
|
//
|
|
|
|
// go run main.go STAY
|
|
|
|
// Search Results:
|
|
|
|
// + Stay Golden
|
|
|
|
//
|
|
|
|
// go run main.go sTaY
|
|
|
|
// Search Results:
|
|
|
|
// + Stay Golden
|
|
|
|
//
|
|
|
|
// go run main.go "Kafka's Revenge"
|
|
|
|
// Search Results:
|
|
|
|
// + Kafka's Revenge
|
|
|
|
// + Kafka's Revenge 2nd Edition
|
|
|
|
//
|
|
|
|
// go run main.go void
|
|
|
|
// Search Results:
|
|
|
|
// We don't have the book: "void"
|
2018-12-06 00:20:27 +03:00
|
|
|
//
|
|
|
|
// HINTS:
|
|
|
|
// + To find out whether a string contains another string value, you can use the strings.Contains function.
|
|
|
|
// + To convert a string value to lowercase, you can use the strings.ToLower function.
|
|
|
|
// + Check out the strings package for more information.
|
2018-12-05 15:02:03 +03:00
|
|
|
// ---------------------------------------------------------
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
}
|