Skip to content
Closed
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ linters-settings:

Unmarshal and Scan methods are excluded by default as they must use pointer receivers:
- `*.UnmarshalText`, `*.UnmarshalJSON`, `*.UnmarshalJSONFrom`, `*.UnmarshalYAML`
- `*.UnmarshalXML`, `*.UnmarshalBinary`, `*.GobDecode`, `*.Scan`
- `*.UnmarshalXML`, `*.UnmarshalBinary`, `*.GobDecode`, `*.UnmarshalMapstructure`, `*.Scan`

## Examples

Expand Down
18 changes: 10 additions & 8 deletions analyzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ func NewAnalyzer(s Settings) *analysis.Analyzer {
if !s.DisableBuiltin {
// Default excludes for Unmarshal/Decode methods https://github.com/raeperd/recvcheck/issues/17
a.excluded = map[string]struct{}{
"*.UnmarshalText": {},
"*.UnmarshalJSON": {},
"*.UnmarshalJSONFrom": {},
"*.UnmarshalYAML": {},
"*.UnmarshalXML": {},
"*.UnmarshalBinary": {},
"*.GobDecode": {},
"*.Scan": {},
"*.UnmarshalText": {},
"*.UnmarshalJSON": {},
"*.UnmarshalJSONFrom": {},
"*.UnmarshalYAML": {},
"*.UnmarshalXML": {},
"*.UnmarshalBinary": {},
"*.GobDecode": {},
"*.UnmarshalMapstructure": {},
"*.Scan": {},
}
}

Expand All @@ -52,6 +53,7 @@ type Settings struct {
// - "UnmarshalXML"
// - "UnmarshalBinary"
// - "GobDecode"
// - "UnmarshalMapstructure"
// - "Scan"
DisableBuiltin bool

Expand Down
11 changes: 11 additions & 0 deletions testdata/src/builtinmethods/mapstructure.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package builtinmethods

type Mapstructure struct{}

func (m Mapstructure) String() string {
panic("not implemented")
}

func (m *Mapstructure) UnmarshalMapstructure(input any) error {
panic("not implemented")
}
11 changes: 11 additions & 0 deletions testdata/src/disablebuiltin/mapstructure.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package disablebuiltin

type Mapstructure struct{} // want `the methods of "Mapstructure" use pointer receiver and non-pointer receiver.`

func (m Mapstructure) String() string {
panic("not implemented")
}

func (m *Mapstructure) UnmarshalMapstructure(input any) error {
panic("not implemented")
}
11 changes: 11 additions & 0 deletions testdata/src/disablebuiltin/mapstructure.go.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package disablebuiltin

type Mapstructure struct{} // want `the methods of "Mapstructure" use pointer receiver and non-pointer receiver.`

func (m *Mapstructure) String() string {
panic("not implemented")
}

func (m *Mapstructure) UnmarshalMapstructure(input any) error {
panic("not implemented")
}