carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1package fixture
2
3// Not compiled. A field is a sentence only if every write to a field of that
4// name is. The anonymous struct writes an error's text, positionally and by key.
5
6type Check struct{ Reason string }
7
8func good() Check { return Check{Reason: "this box has no secrets key"} }
9
10func positional(w int, err error) {
11 box := struct{ Reason string }{err.Error()}
12 jsonError(w, 400, box.Reason)
13}
14
15func keyed(w int, err error) {
16 box := struct{ Reason string }{Reason: err.Error()}
17 jsonError(w, 400, box.Reason)
18}
19
20func assigned(w int, err error, c Check) {
21 c.Reason = err.Error()
22 jsonError(w, 400, c.Reason)
23}
24