Files

46 lines
860 B
Go
Raw Permalink Normal View History

2018-11-15 16:37:09 +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-11-15 16:37:09 +03:00
package main
import (
"fmt"
"os"
"strings"
)
func main() {
2018-12-05 15:02:03 +03:00
books := [4]string{
"Kafka's Revenge",
"Stay Golden",
"Everythingship",
"Kafka's Revenge 2nd Edition",
}
2018-12-05 15:02:03 +03:00
args := os.Args[1:]
if len(args) != 1 {
fmt.Println("Tell me a book title")
return
}
2018-12-05 15:02:03 +03:00
query := strings.ToLower(args[0])
fmt.Println("Search Results:")
var found bool
for _, v := range books {
if strings.Contains(strings.ToLower(v), query) {
fmt.Println("+", v)
found = true
}
}
if !found {
2018-12-05 15:02:03 +03:00
fmt.Printf("We don't have the book: %q\n", query)
}
}