From b73967dbd93592e054a957a4aa4cec2e59abe3d0 Mon Sep 17 00:00:00 2001 From: Harald Nordgren Date: Sun, 28 Jul 2024 14:41:15 +0200 Subject: [PATCH 1/2] Fix GitHub check annotations --- internal/template/template_data.go | 1 + pkg/moq/testpackages/anonimport/iface.go | 1 + .../testpackages/anonimport/second_file.go | 2 +- pkg/moq/testpackages/blankid/swallower.go | 1 + .../genericreturn/genericreturn.go | 2 ++ .../otherpackage/otherpackage.go | 1 + pkg/moq/testpackages/generics/generics.go | 6 ++++++ pkg/moq/testpackages/genparamname/iface.go | 5 ++++- pkg/moq/testpackages/importalias/middleman.go | 1 + .../importalias/source/client/src_client.go | 1 + .../importalias/target/client/tgt_client.go | 1 + pkg/moq/testpackages/paramconflict/iface.go | 1 + pkg/moq/testpackages/shadow/http/thing.go | 1 + .../testpackages/shadowtypes/shadowtypes.go | 20 +++++++++++++++++++ 14 files changed, 42 insertions(+), 2 deletions(-) diff --git a/internal/template/template_data.go b/internal/template/template_data.go index 2a3caeb..eb39fc9 100644 --- a/internal/template/template_data.go +++ b/internal/template/template_data.go @@ -90,6 +90,7 @@ func (m MethodData) ReturnArgNameList() string { return strings.Join(params, ", ") } +// TypeParamData extends ParamData with a constraint. type TypeParamData struct { ParamData Constraint types.Type diff --git a/pkg/moq/testpackages/anonimport/iface.go b/pkg/moq/testpackages/anonimport/iface.go index a56856a..12dbd1d 100644 --- a/pkg/moq/testpackages/anonimport/iface.go +++ b/pkg/moq/testpackages/anonimport/iface.go @@ -4,6 +4,7 @@ import ( "context" ) +// Example is a test interface. type Example interface { Ctx(ctx context.Context) } diff --git a/pkg/moq/testpackages/anonimport/second_file.go b/pkg/moq/testpackages/anonimport/second_file.go index c4cadf2..028ec63 100644 --- a/pkg/moq/testpackages/anonimport/second_file.go +++ b/pkg/moq/testpackages/anonimport/second_file.go @@ -1,5 +1,5 @@ package anonimport import ( - _ "context" + _ "context" // import for side effects ) diff --git a/pkg/moq/testpackages/blankid/swallower.go b/pkg/moq/testpackages/blankid/swallower.go index 7d73d7b..1fe3d31 100644 --- a/pkg/moq/testpackages/blankid/swallower.go +++ b/pkg/moq/testpackages/blankid/swallower.go @@ -1,5 +1,6 @@ package blankid +// Swallower is a test interface. type Swallower interface { Swallow(_ string) } diff --git a/pkg/moq/testpackages/genericreturn/genericreturn.go b/pkg/moq/testpackages/genericreturn/genericreturn.go index da23042..507ff35 100644 --- a/pkg/moq/testpackages/genericreturn/genericreturn.go +++ b/pkg/moq/testpackages/genericreturn/genericreturn.go @@ -2,10 +2,12 @@ package genericreturn import "github.com/matryer/moq/pkg/moq/testpackages/genericreturn/otherpackage" +// GenericBar is a test type. type GenericBar[T any] struct { Bar T } +// IFooBar is a test interface. type IFooBar interface { Foobar() GenericBar[otherpackage.Foo] } diff --git a/pkg/moq/testpackages/genericreturn/otherpackage/otherpackage.go b/pkg/moq/testpackages/genericreturn/otherpackage/otherpackage.go index e755f52..241acbc 100644 --- a/pkg/moq/testpackages/genericreturn/otherpackage/otherpackage.go +++ b/pkg/moq/testpackages/genericreturn/otherpackage/otherpackage.go @@ -1,5 +1,6 @@ package otherpackage +// Foo is a test struct. type Foo struct { A int B string diff --git a/pkg/moq/testpackages/generics/generics.go b/pkg/moq/testpackages/generics/generics.go index 9e7a82c..22bed5b 100644 --- a/pkg/moq/testpackages/generics/generics.go +++ b/pkg/moq/testpackages/generics/generics.go @@ -5,26 +5,32 @@ import ( "fmt" ) +// GenericStore1 is a test interface. type GenericStore1[T Key1, S any] interface { Get(ctx context.Context, id T) (S, error) Create(ctx context.Context, id T, value S) error } +// GenericStore2 is a test interface. type GenericStore2[T Key2, S any] interface { Get(ctx context.Context, id T) (S, error) Create(ctx context.Context, id T, value S) error } +// AliasStore is a test interface. type AliasStore GenericStore1[KeyImpl, bool] +// Key1 is a test interface. type Key1 interface { fmt.Stringer } +// Key2 is a test interface. type Key2 interface { ~[]byte | string } +// KeyImpl is a test type. type KeyImpl []byte func (x KeyImpl) String() string { diff --git a/pkg/moq/testpackages/genparamname/iface.go b/pkg/moq/testpackages/genparamname/iface.go index 2ceaf45..83e3272 100644 --- a/pkg/moq/testpackages/genparamname/iface.go +++ b/pkg/moq/testpackages/genparamname/iface.go @@ -12,10 +12,13 @@ import ( ) type ( - Go func() + // Go is a test function. + Go func() + myType struct{} ) +// Interface is a test interface. type Interface interface { Method( *myType, diff --git a/pkg/moq/testpackages/importalias/middleman.go b/pkg/moq/testpackages/importalias/middleman.go index 831394f..b012307 100644 --- a/pkg/moq/testpackages/importalias/middleman.go +++ b/pkg/moq/testpackages/importalias/middleman.go @@ -5,6 +5,7 @@ import ( tgtclient "github.com/matryer/moq/pkg/moq/testpackages/importalias/target/client" ) +// MiddleMan is a test interface. type MiddleMan interface { Connect(src srcclient.Client, tgt tgtclient.Client) } diff --git a/pkg/moq/testpackages/importalias/source/client/src_client.go b/pkg/moq/testpackages/importalias/source/client/src_client.go index 54cf8ad..78598dd 100644 --- a/pkg/moq/testpackages/importalias/source/client/src_client.go +++ b/pkg/moq/testpackages/importalias/source/client/src_client.go @@ -1,3 +1,4 @@ package client +// Client is a test struct. type Client struct{} diff --git a/pkg/moq/testpackages/importalias/target/client/tgt_client.go b/pkg/moq/testpackages/importalias/target/client/tgt_client.go index 54cf8ad..78598dd 100644 --- a/pkg/moq/testpackages/importalias/target/client/tgt_client.go +++ b/pkg/moq/testpackages/importalias/target/client/tgt_client.go @@ -1,3 +1,4 @@ package client +// Client is a test struct. type Client struct{} diff --git a/pkg/moq/testpackages/paramconflict/iface.go b/pkg/moq/testpackages/paramconflict/iface.go index b02e5fd..e4829fd 100644 --- a/pkg/moq/testpackages/paramconflict/iface.go +++ b/pkg/moq/testpackages/paramconflict/iface.go @@ -2,6 +2,7 @@ package paramconflict import "time" +// Interface is a test interface. type Interface interface { Method(string, bool, string, bool, int, int32, int64, float32, float64, time.Time, time.Time) } diff --git a/pkg/moq/testpackages/shadow/http/thing.go b/pkg/moq/testpackages/shadow/http/thing.go index 5d4c621..7bbd5e2 100644 --- a/pkg/moq/testpackages/shadow/http/thing.go +++ b/pkg/moq/testpackages/shadow/http/thing.go @@ -2,6 +2,7 @@ package http import "net/http" +// Thing is a test interface. type Thing interface { Blah(w http.ResponseWriter, r *http.Request) } diff --git a/pkg/moq/testpackages/shadowtypes/shadowtypes.go b/pkg/moq/testpackages/shadowtypes/shadowtypes.go index 3c0e104..6032c2c 100644 --- a/pkg/moq/testpackages/shadowtypes/shadowtypes.go +++ b/pkg/moq/testpackages/shadowtypes/shadowtypes.go @@ -4,32 +4,52 @@ import ( "github.com/matryer/moq/pkg/moq/testpackages/shadowtypes/types" ) +// ShadowTypes is a test interface. type ShadowTypes interface { + // ShadowString is a test method. ShadowString(string, types.String) + // ShadowInt is a test method. ShadowInt(int, types.Int) + // ShadowInt8 is a test method. ShadowInt8(int8, types.Int8) + // ShadowInt16 is a test method. ShadowInt16(int16, types.Int16) + // ShadowInt32 is a test method. ShadowInt32(int32, types.Int32) + // ShadowInt64 is a test method. ShadowInt64(int64, types.Int64) + // ShadowUint is a test method. ShadowUint(uint, types.Uint) + // ShadowUint8 is a test method. ShadowUint8(uint8, types.Uint8) + // ShadowUint16 is a test method. ShadowUint16(uint16, types.Uint16) + // ShadowUint32 is a test method. ShadowUint32(uint32, types.Uint32) + // ShadowUint64 is a test method. ShadowUint64(uint64, types.Uint64) + // ShadowFloat32 is a test method. ShadowFloat32(float32, types.Float32) + // ShadowFloat64 is a test method. ShadowFloat64(float64, types.Float64) + // ShadowByte is a test method. ShadowByte(byte, types.Byte) + // ShadowRune is a test method. ShadowRune(rune, types.Rune) + // ShadowBool is a test method. ShadowBool(bool, types.Bool) + // ShadowComplex64 is a test method. ShadowComplex64(complex64, types.Complex64) + // ShadowComplex128 is a test method. ShadowComplex128(complex128, types.Complex128) + // ShadowUintptr is a test method. ShadowUintptr(uintptr, types.Uintptr) } From c097d10306adbfe06691d1573219d0b91e14401d Mon Sep 17 00:00:00 2001 From: Harald Nordgren Date: Sun, 28 Jul 2024 21:15:08 +0200 Subject: [PATCH 2/2] Update types.go --- .../testpackages/shadowtypes/types/types.go | 19 +++++++++++++++++++ pkg/moq/testpackages/syncimport/sync/thing.go | 1 + pkg/moq/testpackages/syncimport/syncer.go | 1 + .../testpackages/transientimport/base/type.go | 1 + .../transientimport/four/app/v1/four.go | 1 + .../transientimport/one/v1/one.go | 1 + .../transientimport/onev1/zero.go | 1 + .../transientimport/three/v1/three.go | 1 + .../testpackages/transientimport/transient.go | 1 + .../transientimport/two/app/v1/two.go | 1 + pkg/moq/testpackages/variadic/echoer.go | 1 + .../sudo-suhas/moq-test-pkgs/somerepo/code.go | 1 + .../sudo-suhas/moq-test-pkgs/somerepo/code.go | 1 + 13 files changed, 31 insertions(+) diff --git a/pkg/moq/testpackages/shadowtypes/types/types.go b/pkg/moq/testpackages/shadowtypes/types/types.go index 66c552e..5d59446 100644 --- a/pkg/moq/testpackages/shadowtypes/types/types.go +++ b/pkg/moq/testpackages/shadowtypes/types/types.go @@ -1,29 +1,48 @@ package types +// String is a test type. type String string +// Int is a test type. type Int int +// Int8 is a test type. type Int8 int8 +// Int16 is a test type. type Int16 int16 +// Int32 is a test type. type Int32 int32 +// Int64 is a test type. type Int64 int64 +// Uint is a test type. type Uint uint +// Uint8 is a test type. type Uint8 uint +// Uint16 is a test type. type Uint16 uint +// Uint32 is a test type. type Uint32 uint +// Uint64 is a test type. type Uint64 uint +// Float32 is a test type. type Float32 float32 +// Float64 is a test type. type Float64 float64 +// Byte is a test type. type Byte byte +// Rune is a test type. type Rune rune +// Bool is a test type. type Bool bool +// Complex64 is a test type. type Complex64 complex64 +// Complex128 is a test type. type Complex128 complex128 +// Uintptr is a test type. type Uintptr uintptr diff --git a/pkg/moq/testpackages/syncimport/sync/thing.go b/pkg/moq/testpackages/syncimport/sync/thing.go index 5af77a9..f44f8fd 100644 --- a/pkg/moq/testpackages/syncimport/sync/thing.go +++ b/pkg/moq/testpackages/syncimport/sync/thing.go @@ -1,3 +1,4 @@ package sync +// Thing is a test type. type Thing string diff --git a/pkg/moq/testpackages/syncimport/syncer.go b/pkg/moq/testpackages/syncimport/syncer.go index 5094284..9ac5464 100644 --- a/pkg/moq/testpackages/syncimport/syncer.go +++ b/pkg/moq/testpackages/syncimport/syncer.go @@ -6,6 +6,7 @@ import ( "github.com/matryer/moq/pkg/moq/testpackages/syncimport/sync" ) +// Syncer is a test interface. type Syncer interface { Blah(s sync.Thing, wg *stdsync.WaitGroup) } diff --git a/pkg/moq/testpackages/transientimport/base/type.go b/pkg/moq/testpackages/transientimport/base/type.go index f099285..e51c445 100644 --- a/pkg/moq/testpackages/transientimport/base/type.go +++ b/pkg/moq/testpackages/transientimport/base/type.go @@ -8,6 +8,7 @@ import ( two "github.com/matryer/moq/pkg/moq/testpackages/transientimport/two/app/v1" ) +// Transient is a test interface. type Transient interface { DoSomething(onev1.Zero, one.One, two.Two, three.Three, four.Four) } diff --git a/pkg/moq/testpackages/transientimport/four/app/v1/four.go b/pkg/moq/testpackages/transientimport/four/app/v1/four.go index ba02f3a..3661286 100644 --- a/pkg/moq/testpackages/transientimport/four/app/v1/four.go +++ b/pkg/moq/testpackages/transientimport/four/app/v1/four.go @@ -1,3 +1,4 @@ package v1 +// Four is a test type. type Four string diff --git a/pkg/moq/testpackages/transientimport/one/v1/one.go b/pkg/moq/testpackages/transientimport/one/v1/one.go index 0608265..2cef63b 100644 --- a/pkg/moq/testpackages/transientimport/one/v1/one.go +++ b/pkg/moq/testpackages/transientimport/one/v1/one.go @@ -1,3 +1,4 @@ package v1 +// One is a test type. type One string diff --git a/pkg/moq/testpackages/transientimport/onev1/zero.go b/pkg/moq/testpackages/transientimport/onev1/zero.go index fd94c32..35260d0 100644 --- a/pkg/moq/testpackages/transientimport/onev1/zero.go +++ b/pkg/moq/testpackages/transientimport/onev1/zero.go @@ -1,3 +1,4 @@ package onev1 +// Zero is a test type. type Zero string diff --git a/pkg/moq/testpackages/transientimport/three/v1/three.go b/pkg/moq/testpackages/transientimport/three/v1/three.go index 3287196..dd48e9b 100644 --- a/pkg/moq/testpackages/transientimport/three/v1/three.go +++ b/pkg/moq/testpackages/transientimport/three/v1/three.go @@ -1,3 +1,4 @@ package v1 +// Three is a test type. type Three string diff --git a/pkg/moq/testpackages/transientimport/transient.go b/pkg/moq/testpackages/transientimport/transient.go index 854d637..7cb6fb2 100644 --- a/pkg/moq/testpackages/transientimport/transient.go +++ b/pkg/moq/testpackages/transientimport/transient.go @@ -4,4 +4,5 @@ import ( "github.com/matryer/moq/pkg/moq/testpackages/transientimport/base" ) +// Transient is a test interface. type Transient = base.Transient diff --git a/pkg/moq/testpackages/transientimport/two/app/v1/two.go b/pkg/moq/testpackages/transientimport/two/app/v1/two.go index 6e0f040..cc06174 100644 --- a/pkg/moq/testpackages/transientimport/two/app/v1/two.go +++ b/pkg/moq/testpackages/transientimport/two/app/v1/two.go @@ -1,3 +1,4 @@ package v1 +// Two is a test type. type Two string diff --git a/pkg/moq/testpackages/variadic/echoer.go b/pkg/moq/testpackages/variadic/echoer.go index b830b65..7205984 100644 --- a/pkg/moq/testpackages/variadic/echoer.go +++ b/pkg/moq/testpackages/variadic/echoer.go @@ -1,5 +1,6 @@ package variadic +// Echoer is an interface. type Echoer interface { Echo(ss ...string) []string } diff --git a/pkg/moq/testpackages/vendor/github.com/sudo-suhas/moq-test-pkgs/somerepo/code.go b/pkg/moq/testpackages/vendor/github.com/sudo-suhas/moq-test-pkgs/somerepo/code.go index d5fbd14..658df75 100644 --- a/pkg/moq/testpackages/vendor/github.com/sudo-suhas/moq-test-pkgs/somerepo/code.go +++ b/pkg/moq/testpackages/vendor/github.com/sudo-suhas/moq-test-pkgs/somerepo/code.go @@ -8,6 +8,7 @@ type SomeType struct { Truth bool } +// SomeService is a test interface. type SomeService interface { Get() SomeType } diff --git a/pkg/moq/testpackages/vendoring/vendor/github.com/sudo-suhas/moq-test-pkgs/somerepo/code.go b/pkg/moq/testpackages/vendoring/vendor/github.com/sudo-suhas/moq-test-pkgs/somerepo/code.go index d5fbd14..658df75 100644 --- a/pkg/moq/testpackages/vendoring/vendor/github.com/sudo-suhas/moq-test-pkgs/somerepo/code.go +++ b/pkg/moq/testpackages/vendoring/vendor/github.com/sudo-suhas/moq-test-pkgs/somerepo/code.go @@ -8,6 +8,7 @@ type SomeType struct { Truth bool } +// SomeService is a test interface. type SomeService interface { Get() SomeType }