Skip to content

Commit

Permalink
handler: drop the special case for "jrpc" tags
Browse files Browse the repository at this point in the history
This code path was inadequately tested and not visibly used.  The idea was to
give a hook for custom unmarshalers, but for that purpose the library does not
need to do anything special -- the implementation can look up tags if it wants
to, or do something else.
  • Loading branch information
creachadair committed Jan 18, 2023
1 parent 0eae5d2 commit 3ea9a41
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 11 deletions.
5 changes: 0 additions & 5 deletions handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,6 @@ func (fi *FuncInfo) Wrap() Func {
// Otherwise, if the field has a `json:"name"` tag and the name is not empty,
// "name" is used.
//
// Otherwise, if the field nas a `jrpc:"name"` tag, "name" is used. Note: This
// case is meant to support types with custom implementations of UnmarshalJSON.
// Assigning a name that does not match the field name can cause json.Unmarshal
// to report an error.
//
// Otherwise, if the field is anonymous (embedded) it is skipped. To include an
// anonymous field, ensure it is tagged for one of the previous rules.
//
Expand Down
4 changes: 2 additions & 2 deletions handler/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ func TestCheck_structArg(t *testing.T) {
B int `json:"-"`
C bool `json:",omitempty"`
D byte // unspecified, use default name
Evil int `jrpc:"evil"`
Evil int `json:"eee"`
}

const base = `{"jsonrpc":"2.0","id":1,"method":"M","params":%s}`
const inputObj = `{"apple":"1","c":true,"d":25,"evil":666}`
const inputObj = `{"apple":"1","c":true,"d":25,"eee":666}`
const inputArray = `["1", true, 25, 666]`
fail := errors.New("fail")

Expand Down
4 changes: 0 additions & 4 deletions handler/positional.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ func structFieldNames(atype reflect.Type) (bool, []string) {
}
// fall through to other cases
}
if tag, ok := fi.Tag.Lookup("jrpc"); ok {
names = append(names, tag)
continue
}
if fi.Anonymous {
// This is an untagged anonymous field. Tagged anonymous fields are
// handled by the cases above.
Expand Down

0 comments on commit 3ea9a41

Please sign in to comment.