go-by-test/dictionary/dictionary.go

16 lines
291 B
Go

package dictionary
import "errors"
type Dictionary map[string]string
var ErrNotFound = errors.New("could not find the word you were looking for")
func (d Dictionary) Search(word string) (string, error) {
result, ok := d[word]
if !ok {
return "", ErrNotFound
}
return result, nil
}