tailcfg: add omitempty to all fields of Hostinfo (#4360)

This reduces the noise when marshaling only a subset of this type.

Signed-off-by: Joe Tsai <joetsai@digital-static.net>
This commit is contained in:
Joe Tsai
2022-04-05 13:25:14 -07:00
committed by GitHub
parent ac2033d98c
commit 01adcfa688
2 changed files with 3 additions and 5 deletions

View File

@@ -217,7 +217,7 @@ func TestJSON(t *testing.T) {
var buf bytes.Buffer
var logf Logf = func(f string, a ...any) { fmt.Fprintf(&buf, f, a...) }
logf.JSON(1, "foo", &tailcfg.Hostinfo{})
want := "[v\x00JSON]1" + `{"foo":{"OS":"","Hostname":""}}`
want := "[v\x00JSON]1" + `{"foo":{}}`
if got := buf.String(); got != want {
t.Errorf("mismatch\n got: %q\nwant: %q\n", got, want)
}