diff --git a/methods.go b/methods.go index 38af0be..52e7eb5 100644 --- a/methods.go +++ b/methods.go @@ -81,6 +81,7 @@ func (m *MethodsValidator) Validate(v *ast.FuncDecl, fset *token.FileSet) error if m.lastType != rcvType.Name { m.sortedTypes.identType = "Type" + m.sortedMethods = sortedNamesValidator{} if err := validateSorted(&m.sortedTypes, rcvType, false); err != nil { return err } diff --git a/methods_test.go b/methods_test.go index cdc41a3..5aed41f 100644 --- a/methods_test.go +++ b/methods_test.go @@ -30,6 +30,11 @@ func TestMethodsValidator_Validate(t *testing.T) { "methods_sorted_type_ok.go", false, }, + { + "OK: sorted exported/unexported", + "methods_sorted_unexported_ok.go", + false, + }, { "Error: not defined in file", "methods_not_defined.go", diff --git a/testdata/methods_sorted_unexported_ok.go b/testdata/methods_sorted_unexported_ok.go new file mode 100644 index 0000000..a2e6356 --- /dev/null +++ b/testdata/methods_sorted_unexported_ok.go @@ -0,0 +1,14 @@ +package testdata + +type ( + MethodSortedTypeUnexported_A struct{} + MethodSortedTypeUnexported_B struct{} +) + +func (MethodSortedTypeUnexported_A) A() {} +func (MethodSortedTypeUnexported_A) B() {} +func (*MethodSortedTypeUnexported_A) c() {} + +//- + +func (MethodSortedTypeUnexported_B) A() {}