-
Notifications
You must be signed in to change notification settings - Fork 0
/
book.go
80 lines (76 loc) · 1.54 KB
/
book.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package main
import "fmt"
type Book struct {
ID int
Title string
Author string
YearPublished int
}
func (b Book) String() string {
return fmt.Sprintf(
"Title:\t\t%q\n"+
"Author:\t\t%q\n"+
"Published:\t%v\n", b.Title, b.Author, b.YearPublished)
}
var books = []Book{
{
ID: 1,
Title: "The Hitchhiker's Guide to the Galaxy",
Author: "Douglas Admas",
YearPublished: 1979,
},
{
ID: 2,
Title: "The Hobbit",
Author: "J.R.R Tolkien",
YearPublished: 1937,
},
{
ID: 3,
Title: "A Tale of Two Cities",
Author: "Charles Dickens",
YearPublished: 1859,
},
{
ID: 4,
Title: "Les Misérables",
Author: "Victor Hugo",
YearPublished: 1962,
},
{
ID: 5,
Title: "Harry Potter and the Philosopher's Stone",
Author: "J.K. Rowling",
YearPublished: 1997,
},
{
ID: 6,
Title: "I, Robot",
Author: "Isaac Asimov",
YearPublished: 1950,
},
{
ID: 7,
Title: "The Gods Themselves",
Author: "Isaac Asimov",
YearPublished: 1973,
},
{
ID: 8,
Title: "The Moon is a Harsh Mistress",
Author: "Robert A. Heinlein",
YearPublished: 1966,
},
{
ID: 9,
Title: "On Basilisk Station",
Author: "David Weber",
YearPublished: 1993,
},
{
ID: 10,
Title: "The Android's Dream",
Author: "John Scalzi",
YearPublished: 2006,
},
}