I use a pattern where a variable is declared outside of an if-block and the block determines the value to assign to it. The compiler does not like the following code and reports: "result declared but not used". It looks proper to me... Please explain what I am misunderstanding.
Thank you for your help, Mike
func blah() {
var result error = nil // "result declared but not used"
if 1 == 1 {
result = fmt.Errorf("ouch")
}
}