Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit 03f009e

Browse files
authored
go fmt with Go 1.20 (#16)
from Go 1.19, `go fmt` reformats doc comments. https://go.dev/doc/go1.19#go-doc > Go 1.19 adds support for links, lists, and clearer headings in doc comments. As part of this change, [gofmt](https://go.dev/cmd/gofmt) now reformats doc comments to make their rendered meaning clearer. See “[Go Doc Comments](https://go.dev/doc/comment)” for syntax details and descriptions of common mistakes now highlighted by gofmt. As another part of this change, the new package [go/doc/comment](https://go.dev/pkg/go/doc/comment/) provides parsing and reformatting of doc comments as well as support for rendering them to HTML, Markdown, and text.
1 parent ce92d72 commit 03f009e

File tree

10 files changed

+65
-52
lines changed

10 files changed

+65
-52
lines changed

gomock/controller.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,24 @@ type cleanuper interface {
5151
// goroutines. Each test should create a new Controller and invoke Finish via
5252
// defer.
5353
//
54-
// func TestFoo(t *testing.T) {
55-
// ctrl := gomock.NewController(t)
56-
// defer ctrl.Finish()
57-
// // ..
58-
// }
54+
// func TestFoo(t *testing.T) {
55+
// ctrl := gomock.NewController(t)
56+
// defer ctrl.Finish()
57+
// // ..
58+
// }
5959
//
60-
// func TestBar(t *testing.T) {
61-
// t.Run("Sub-Test-1", st) {
62-
// ctrl := gomock.NewController(st)
63-
// defer ctrl.Finish()
64-
// // ..
65-
// })
66-
// t.Run("Sub-Test-2", st) {
67-
// ctrl := gomock.NewController(st)
68-
// defer ctrl.Finish()
69-
// // ..
70-
// })
71-
// })
60+
// func TestBar(t *testing.T) {
61+
// t.Run("Sub-Test-1", st) {
62+
// ctrl := gomock.NewController(st)
63+
// defer ctrl.Finish()
64+
// // ..
65+
// })
66+
// t.Run("Sub-Test-2", st) {
67+
// ctrl := gomock.NewController(st)
68+
// defer ctrl.Finish()
69+
// // ..
70+
// })
71+
// })
7272
type Controller struct {
7373
// T should only be called within a generated mock. It is not intended to
7474
// be used in user code and may be changed in future versions. T is the

gomock/doc.go

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,19 @@
1515
// Package gomock is a mock framework for Go.
1616
//
1717
// Standard usage:
18-
// (1) Define an interface that you wish to mock.
19-
// type MyInterface interface {
20-
// SomeMethod(x int64, y string)
21-
// }
22-
// (2) Use mockgen to generate a mock from the interface.
23-
// (3) Use the mock in a test:
24-
// func TestMyThing(t *testing.T) {
25-
// mockCtrl := gomock.NewController(t)//
26-
// mockObj := something.NewMockMyInterface(mockCtrl)
27-
// mockObj.EXPECT().SomeMethod(4, "blah")
28-
// // pass mockObj to a real object and play with it.
29-
// }
18+
//
19+
// (1) Define an interface that you wish to mock.
20+
// type MyInterface interface {
21+
// SomeMethod(x int64, y string)
22+
// }
23+
// (2) Use mockgen to generate a mock from the interface.
24+
// (3) Use the mock in a test:
25+
// func TestMyThing(t *testing.T) {
26+
// mockCtrl := gomock.NewController(t)//
27+
// mockObj := something.NewMockMyInterface(mockCtrl)
28+
// mockObj.EXPECT().SomeMethod(4, "blah")
29+
// // pass mockObj to a real object and play with it.
30+
// }
3031
//
3132
// By default, expected calls are not enforced to run in any particular order.
3233
// Call order dependency can be enforced by use of InOrder and/or Call.After.
@@ -37,17 +38,17 @@
3738
//
3839
// Example of using Call.After to chain expected call order:
3940
//
40-
// firstCall := mockObj.EXPECT().SomeMethod(1, "first")
41-
// secondCall := mockObj.EXPECT().SomeMethod(2, "second").After(firstCall)
42-
// mockObj.EXPECT().SomeMethod(3, "third").After(secondCall)
41+
// firstCall := mockObj.EXPECT().SomeMethod(1, "first")
42+
// secondCall := mockObj.EXPECT().SomeMethod(2, "second").After(firstCall)
43+
// mockObj.EXPECT().SomeMethod(3, "third").After(secondCall)
4344
//
4445
// Example of using InOrder to declare expected call order:
4546
//
46-
// gomock.InOrder(
47-
// mockObj.EXPECT().SomeMethod(1, "first"),
48-
// mockObj.EXPECT().SomeMethod(2, "second"),
49-
// mockObj.EXPECT().SomeMethod(3, "third"),
50-
// )
47+
// gomock.InOrder(
48+
// mockObj.EXPECT().SomeMethod(1, "first"),
49+
// mockObj.EXPECT().SomeMethod(2, "second"),
50+
// mockObj.EXPECT().SomeMethod(3, "third"),
51+
// )
5152
//
5253
// The standard TestReporter most users will pass to `NewController` is a
5354
// `*testing.T` from the context of the test. Note that this will use the

gomock/matchers.go

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,9 @@ func Any() Matcher { return anyMatcher{} }
283283
// Eq returns a matcher that matches on equality.
284284
//
285285
// Example usage:
286-
// Eq(5).Matches(5) // returns true
287-
// Eq(5).Matches(4) // returns false
286+
//
287+
// Eq(5).Matches(5) // returns true
288+
// Eq(5).Matches(4) // returns false
288289
func Eq(x interface{}) Matcher { return eqMatcher{x} }
289290

290291
// Len returns a matcher that matches on length. This matcher returns false if
@@ -296,17 +297,19 @@ func Len(i int) Matcher {
296297
// Nil returns a matcher that matches if the received value is nil.
297298
//
298299
// Example usage:
299-
// var x *bytes.Buffer
300-
// Nil().Matches(x) // returns true
301-
// x = &bytes.Buffer{}
302-
// Nil().Matches(x) // returns false
300+
//
301+
// var x *bytes.Buffer
302+
// Nil().Matches(x) // returns true
303+
// x = &bytes.Buffer{}
304+
// Nil().Matches(x) // returns false
303305
func Nil() Matcher { return nilMatcher{} }
304306

305307
// Not reverses the results of its given child matcher.
306308
//
307309
// Example usage:
308-
// Not(Eq(5)).Matches(4) // returns true
309-
// Not(Eq(5)).Matches(5) // returns false
310+
//
311+
// Not(Eq(5)).Matches(4) // returns true
312+
// Not(Eq(5)).Matches(5) // returns false
310313
func Not(x interface{}) Matcher {
311314
if m, ok := x.(Matcher); ok {
312315
return notMatcher{m}
@@ -318,12 +321,13 @@ func Not(x interface{}) Matcher {
318321
// function is assignable to the type of the parameter to this function.
319322
//
320323
// Example usage:
321-
// var s fmt.Stringer = &bytes.Buffer{}
322-
// AssignableToTypeOf(s).Matches(time.Second) // returns true
323-
// AssignableToTypeOf(s).Matches(99) // returns false
324324
//
325-
// var ctx = reflect.TypeOf((*context.Context)(nil)).Elem()
326-
// AssignableToTypeOf(ctx).Matches(context.Background()) // returns true
325+
// var s fmt.Stringer = &bytes.Buffer{}
326+
// AssignableToTypeOf(s).Matches(time.Second) // returns true
327+
// AssignableToTypeOf(s).Matches(99) // returns false
328+
//
329+
// var ctx = reflect.TypeOf((*context.Context)(nil)).Elem()
330+
// AssignableToTypeOf(ctx).Matches(context.Background()) // returns true
327331
func AssignableToTypeOf(x interface{}) Matcher {
328332
if xt, ok := x.(reflect.Type); ok {
329333
return assignableToTypeOfMatcher{xt}
@@ -334,8 +338,9 @@ func AssignableToTypeOf(x interface{}) Matcher {
334338
// InAnyOrder is a Matcher that returns true for collections of the same elements ignoring the order.
335339
//
336340
// Example usage:
337-
// InAnyOrder([]int{1, 2, 3}).Matches([]int{1, 3, 2}) // returns true
338-
// InAnyOrder([]int{1, 2, 3}).Matches([]int{1, 2}) // returns false
341+
//
342+
// InAnyOrder([]int{1, 2, 3}).Matches([]int{1, 3, 2}) // returns true
343+
// InAnyOrder([]int{1, 2, 3}).Matches([]int{1, 2}) // returns false
339344
func InAnyOrder(x interface{}) Matcher {
340345
return inAnyOrderMatcher{x}
341346
}

mockgen/internal/tests/import_embedded_interface/bugreport_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14+
1415
package bugreport
1516

1617
import (

mockgen/internal/tests/import_embedded_interface/ersatz/ersatz.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14+
1415
package ersatz
1516

1617
type Embedded interface {

mockgen/internal/tests/import_embedded_interface/faux/conflict.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14+
1415
package faux
1516

1617
import "go.uber.org/mock/mockgen/internal/tests/import_embedded_interface/other/log"

mockgen/internal/tests/import_embedded_interface/faux/faux.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14+
1415
package faux
1516

1617
import (

mockgen/internal/tests/import_embedded_interface/net_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14+
1415
package bugreport
1516

1617
import (

mockgen/internal/tests/import_embedded_interface/other/ersatz/ersatz.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14+
1415
package ersatz
1516

1617
type Embedded interface {

mockgen/internal/tests/import_embedded_interface/other/log/log.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
14+
1415
package log
1516

1617
func Foo() {}

0 commit comments

Comments
 (0)