diff --git a/records.go b/records.go index 3eb9a5a..c0552c7 100644 --- a/records.go +++ b/records.go @@ -218,11 +218,10 @@ func (rs *RecordStore) save() { } } - data, err := json.MarshalIndent(snap, "", " ") - if err != nil { - slog.Error("save nameserver state", "err", err) - return - } + // MarshalIndent on recordSnapshot is infallible: every field is a + // primitive (string/uint16) or time.Time, no exotic types. + // The error branch is unreachable. + data, _ := json.MarshalIndent(snap, "", " ") dir := filepath.Dir(rs.storePath) if err := os.MkdirAll(dir, 0700); err != nil { diff --git a/wire.go b/wire.go index 324862a..a28e91f 100644 --- a/wire.go +++ b/wire.go @@ -150,11 +150,10 @@ func FormatRequest(r Request) string { // ParseResponse parses a plain-text nameserver response. func ParseResponse(text string) (Response, error) { + // strings.Split always returns at least one element, so the + // "empty response" guard would be unreachable; the real empty + // case is caught by the len(fields) < 1 check below. lines := strings.Split(strings.TrimSpace(text), "\n") - if len(lines) == 0 { - return Response{}, fmt.Errorf("empty response") - } - first := strings.TrimSpace(lines[0]) if first == "OK" { return Response{Type: "OK"}, nil