MCPcopy Create free account
hub / github.com/encodeous/nylon / uapiCfg

Function uapiCfg

polyamide/device/device_test.go:35–49  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

33// For example, a leading blank newline causes the remainder
34// of the config to be silently ignored.
35func 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.

Callers 2

genConfigsFunction · 0.85
TestConcurrencySafetyFunction · 0.85

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected