Download this file
| 1 | package fixture |
| 2 | |
| 3 | // Not compiled. The literal writes a recorded sentence, but a later |
| 4 | // assignment takes one result of a multi-value expression into the same |
| 5 | // field. The gate cannot prove that write, so the read is a violation. |
| 6 | |
| 7 | type refusal struct{ Reason string } |
| 8 | |
| 9 | func detail(err error) (string, error) { |
| 10 | return err.Error(), nil |
| 11 | } |
| 12 | |
| 13 | func multi(w int, err error) { |
| 14 | box := refusal{Reason: "invalid region"} |
| 15 | box.Reason, _ = detail(err) |
| 16 | jsonError(w, 400, box.Reason) |
| 17 | } |
| 18 | |
| 19 | func commaOK(w int, names map[string]string, k string) { |
| 20 | box := refusal{Reason: "invalid region"} |
| 21 | var ok bool |
| 22 | box.Reason, ok = names[k] |
| 23 | _ = ok |
| 24 | jsonError(w, 400, box.Reason) |
| 25 | } |
| 26 | |