The following works in tests:
if actualKey != expectedKey {
t.Fatalf("Failed. Actual: %q. Expected: %q", actualKey, expectedKey)
}
In the main code:
m["Keyword "+kw+" found on "+url] = 0
, but this fails:
m["Keyword %q found on %q", kw, url] = 0
As suggested by @JimB fmt.Sprintf could be used. The following works:
msg := fmt.Sprintf("Keyword %q found on %q", kw, url)
m[msg] = 0
Questions
variable referencing
? If false, what is it called?I think a better way to do it is by defining a struct type:
type Result struct {
Keyword, URL string
}
and use it like this:
m := make(map[Result]int)
m[{"keyword1", "url1"}] = 0