From aca1890ec1b2e3a58411e4cb1d7b9324e704a20c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Mengu=C3=A9?= Date: Thu, 7 Mar 2024 11:59:12 +0100 Subject: [PATCH 1/2] mock: document more alternatives to deprecated AnythingOfTypeArgument --- mock/mock.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/mock/mock.go b/mock/mock.go index eca55f6a1..7abce13d1 100644 --- a/mock/mock.go +++ b/mock/mock.go @@ -766,7 +766,25 @@ const ( // AnythingOfTypeArgument contains the type of an argument // for use when type checking. Used in Diff and Assert. // -// Deprecated: this is an implementation detail that must not be used. Use [AnythingOfType] instead. +// Deprecated: this is an implementation detail that must not be used. Use the [AnythingOfType] constructor instead. +// +// If AnythingOfTypeArgument is used as a function return value type you can usually replace +// the function with a variable. Example: +// +// func anyString() mock.AnythingOfTypeArgument { +// return mock.AnythingOfType("string") +// } +// +// Can be replaced by: +// +// func anyString() interface{} { +// return mock.IsType("") +// } +// +// It could even be replaced with a variable: +// +// var anyString = mock.AnythingOfType("string") +// var anyString = mock.IsType("") // alternative type AnythingOfTypeArgument = anythingOfTypeArgument // anythingOfTypeArgument is a string that contains the type of an argument From 8c324a0bbd418741163c17c7219a5f68295ed1d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Mengu=C3=A9?= Date: Tue, 23 Apr 2024 15:23:21 +0200 Subject: [PATCH 2/2] mock: simpler deprecation doc for AnythingOfTypeArgument Co-authored-by: Bracken --- mock/mock.go | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/mock/mock.go b/mock/mock.go index 7abce13d1..84ffcdc63 100644 --- a/mock/mock.go +++ b/mock/mock.go @@ -766,25 +766,15 @@ const ( // AnythingOfTypeArgument contains the type of an argument // for use when type checking. Used in Diff and Assert. // -// Deprecated: this is an implementation detail that must not be used. Use the [AnythingOfType] constructor instead. +// Deprecated: this is an implementation detail that must not be used. Use the [AnythingOfType] constructor instead, example: // -// If AnythingOfTypeArgument is used as a function return value type you can usually replace -// the function with a variable. Example: +// m.On("Do", mock.AnythingOfType("string")) // -// func anyString() mock.AnythingOfTypeArgument { -// return mock.AnythingOfType("string") -// } -// -// Can be replaced by: +// All explicit type declarations can be replaced with interface{} as is expected by [Mock.On], example: // -// func anyString() interface{} { -// return mock.IsType("") +// func anyString interface{} { +// return mock.AnythingOfType("string") // } -// -// It could even be replaced with a variable: -// -// var anyString = mock.AnythingOfType("string") -// var anyString = mock.IsType("") // alternative type AnythingOfTypeArgument = anythingOfTypeArgument // anythingOfTypeArgument is a string that contains the type of an argument