Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions records.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 3 additions & 4 deletions wire.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading