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
3import "fmt"
4
5// Not compiled. MV-N2's format, with its list made by a package helper or
6// read from a string field. Each carries an error's text, or text the gate
7// cannot derive, and no row vouches for that.
8
9func detail(err error) string {
10 return err.Error()
11}
12
13func viaHelper(w int, to string, err error) {
14 jsonError(w, 400, fmt.Sprintf("region %s is not one of this app's regions: %s", to, detail(err)))
15}
16
17func viaHelperConcat(w int, to string, err error) {
18 jsonError(w, 400, "region "+to+" is not one of this app's regions: "+detail(err))
19}
20
21// A helper whose return the gate cannot derive: the receiver is shadowed, so
22// the gate cannot tell which describe runs.
23type local struct{}
24
25func (local) describe() string { return "a recorded sentence" }
26
27func opaque(x local, y thing) string {
28 if x := y; x != nil {
29 return x.describe()
30 }
31 return "a recorded sentence"
32}
33
34func viaOpaque(w int, to string, x local, y thing) {
35 jsonError(w, 400, fmt.Sprintf("region %s is not one of this app's regions: %s", to, opaque(x, y)))
36}
37
38// A helper that returns its parameter, bound to an error's text.
39func echo(m string) string {
40 return m
41}
42
43func viaEcho(w int, to string, err error) {
44 jsonError(w, 400, fmt.Sprintf("region %s is not one of this app's regions: %s", to, echo(fmt.Sprint(err))))
45}
46
47// A string field written from an error's text.
48type failure struct{ Detail string }
49
50func record(err error) failure {
51 return failure{Detail: err.Error()}
52}
53
54func viaField(w int, to string, f failure) {
55 jsonError(w, 400, fmt.Sprintf("region %s is not one of this app's regions: %s", to, f.Detail))
56}
57
58func viaFieldConcat(w int, to string, f failure) {
59 jsonError(w, 400, "region "+to+" is not one of this app's regions: "+f.Detail)
60}
61