Skip to content

Commit

Permalink
Add "implements assertion" for nullstring type
Browse files Browse the repository at this point in the history
Fail the build if the json.Unmarshaler implementation isn't correct.

This resolves the unparam linter error:
(*NullString).UnmarshalJSON - result 0 (error) is always nil (unparam)

refs mvdan/unparam#52
  • Loading branch information
atc0005 committed Apr 29, 2022
1 parent da52885 commit 2f9ce03
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/statuspage/nullstring.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ import (
// https://stackoverflow.com/questions/31048557/assigning-null-to-json-fields-instead-of-empty-strings
// https://stackoverflow.com/questions/25087960/json-unmarshal-time-that-isnt-in-rfc-3339-format/

// Add an "implements assertion" to fail the build if the json.Unmarshaler
// implementation isn't correct.
//
// This resolves the unparam linter error:
// (*NullString).UnmarshalJSON - result 0 (error) is always nil (unparam)
//
// https://github.com/mvdan/unparam/issues/52
var _ json.Unmarshaler = (*NullString)(nil)

// Perform similar "implements assertion" for the json.Marshaler interface.
var _ json.Marshaler = (*NullString)(nil)

// NullString represents a string value used in component fields that may
// potentially be null in the input JSON feed.
type NullString string
Expand Down

0 comments on commit 2f9ce03

Please sign in to comment.