uapiCfg returns a string that contains cfg formatted use with IpcSet. cfg is a series of alternating key/value strings. uapiCfg exists because editors and humans like to insert whitespace into configs, which can cause failures, some of which are silent. For example, a leading blank newline causes th
(cfg ...string)
| 33 | // For example, a leading blank newline causes the remainder |
| 34 | // of the config to be silently ignored. |
| 35 | func uapiCfg(cfg ...string) string { |
| 36 | if len(cfg)%2 != 0 { |
| 37 | panic("odd number of args to uapiReader") |
| 38 | } |
| 39 | buf := new(bytes.Buffer) |
| 40 | for i, s := range cfg { |
| 41 | buf.WriteString(s) |
| 42 | sep := byte('\n') |
| 43 | if i%2 == 0 { |
| 44 | sep = '=' |
| 45 | } |
| 46 | buf.WriteByte(sep) |
| 47 | } |
| 48 | return buf.String() |
| 49 | } |
| 50 | |
| 51 | // genConfigs generates a pair of configs that connect to each other. |
| 52 | // The configs use distinct, probably-usable ports. |
no test coverage detected