Go Gotcha
Go is lexically scoped…
What is wrong with the following code?
// Item
var item *Item
itemID := u.Query().Get("itemID")
if itemID != "" {
item, err := repository.GetItem(itemID)
}
log.Printf("The item %v", item)
The code shows how Item is being redeclared in the scope of the if.
Further reading here: Declarations and scope