A type assertion extracts a value of a specified concrete or interface type from an interface value. It matters when an interface-based API hides the concrete value needed for updates or further processing. In a store, a retrieved interface value can be asserted as a pointer to task.Task before its fields are changed. section 11.5 section 11.3
Retrieving and updating a task
result, err := m.TaskDb.Get(t.ID.String()) if err != nil { log.Printf("%s", err) continue } taskPersisted, ok := result.(*task.Task) if !ok { log.Printf("cannot convert result to task.Task") continue } taskPersisted.State = t.State m.TaskDb.Put(taskPersisted.ID.String(), taskPersisted)




