diff --git a/dictionary/dictionary.go b/dictionary/dictionary.go index d0ce6f6..d65f803 100644 --- a/dictionary/dictionary.go +++ b/dictionary/dictionary.go @@ -1,7 +1,9 @@ package dictionary -func Search(dictionary map[string]string, word string) string { - result, ok := dictionary[word] +type Dictionary map[string]string + +func (d Dictionary) Search(word string) string { + result, ok := d[word] if !ok { return "" } diff --git a/dictionary/dictionary_test.go b/dictionary/dictionary_test.go index bf7b5db..e00bc0f 100644 --- a/dictionary/dictionary_test.go +++ b/dictionary/dictionary_test.go @@ -11,9 +11,9 @@ func assertStrings(t testing.TB, got, want string) { } func TestSearch(t *testing.T) { - dictionary := map[string]string{"test": "this is just a test"} + dictionary := Dictionary{"test": "this is just a test"} - got := Search(dictionary, "test") + got := dictionary.Search("test") want := "this is just a test" assertStrings(t, got, want)