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
- Is it correct to call this approach
variable referencing
? If false, what is it called? - Is this the most concise way of implementing it?