From 1fad83b197d46d3c1ae2922a7a0a41895a779cd9 Mon Sep 17 00:00:00 2001 From: Peter Mescalchin Date: Thu, 9 Nov 2023 17:51:16 +1100 Subject: [PATCH 1/2] Note that `exhaustruct` struct regular expressions are expected to match the entire `package/name/structname` --- .golangci.reference.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.golangci.reference.yml b/.golangci.reference.yml index 248e858389a2..79db37c19dc9 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -356,13 +356,15 @@ linters-settings: - 'example.com/package.ExampleStruct' exhaustruct: - # List of regular expressions to match struct packages and names. + # List of regular expressions to match struct packages and their names. + # Regular expressions must match complete canonical struct package/name/structname. # If this list is empty, all structs are tested. # Default: [] include: - '.*\.Test' - 'example\.com/package\.ExampleStruct[\d]{1,2}' - # List of regular expressions to exclude struct packages and names from check. + # List of regular expressions to exclude struct packages and their names from checks. + # Regular expressions must match complete canonical struct package/name/structname. # Default: [] exclude: - 'cobra\.Command$' From 7df401d2b58e11518570770b7173204c7c84221f Mon Sep 17 00:00:00 2001 From: Peter Mescalchin Date: Thu, 9 Nov 2023 18:04:33 +1100 Subject: [PATCH 2/2] Improve the regexp examples used for `exhaustruct` package/struct matches --- .golangci.reference.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.golangci.reference.yml b/.golangci.reference.yml index 79db37c19dc9..f6df26a421b2 100644 --- a/.golangci.reference.yml +++ b/.golangci.reference.yml @@ -361,13 +361,13 @@ linters-settings: # If this list is empty, all structs are tested. # Default: [] include: - - '.*\.Test' + - '.+\.Test' - 'example\.com/package\.ExampleStruct[\d]{1,2}' # List of regular expressions to exclude struct packages and their names from checks. # Regular expressions must match complete canonical struct package/name/structname. # Default: [] exclude: - - 'cobra\.Command$' + - '.+/cobra\.Command$' forbidigo: # Forbid the following identifiers (list of regexp).