You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/exercises/Exercise2.2.md
+5-6Lines changed: 5 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ A Book Index is an inverted index which lists all pages a word occurs in a book.
8
8
Write a program which generates an inverted index out of an array of book pages.
9
9
Each Page contains an array of words.
10
10
11
-
-Define custom types for Book, Page and Index
11
+
-USe the "type" keyword to define custom types for Book, Page and Index.
12
12
- Make sure the Stringer() interface is implemented for Book and Index to make them printable
13
13
More details about the Stringer interface: https://tour.golang.org/methods/17
14
14
The stringer interface will be explained in more detail in the next lecture.
@@ -21,19 +21,18 @@ Each Page contains an array of words.
21
21
# Usage of the Library functions and error handling
22
22
Write a program "find" that searches the filesystem recursively from a given path and regex expression.
23
23
24
-
1. Use the flag library to provide the following parameters
24
+
1. Use the flag library (https://tour.golang.org/methods/17) to provide the following parameters
25
25
```
26
26
Usage of find:
27
27
-path string
28
28
path to search (default ".")
29
29
-regex string
30
30
path (default ".*")
31
31
```
32
-
33
-
3. Use the ioutil.ReadDir (https://pkg.go.dev/io/ioutil@go1.17.2#ReadDir) function to list the contents of a given directory. Check each file for the given regex with the
32
+
2. Use the ioutil.ReadDir (https://pkg.go.dev/io/ioutil@go1.17.2#ReadDir) function to list the contents of a given directory. Check each file for the given regex with the
34
33
"regexp.MatchString" (https://pkg.go.dev/regexp#MatchString) function and print its path+name on the screen.
35
-
4. Either use "panic" or "log.Fatal" for error handling.
36
-
5. Run through directories recursively
34
+
3. Either use "panic" or "log.Fatal" for error handling.
35
+
4. Run through directories recursively
37
36
38
37
# Question
39
38
Go doesn't support Exceptions but uses multiple return values of which one can be the error information.
0 commit comments