@@ -33,6 +33,7 @@ type Package struct {
33
33
DotImports []string
34
34
}
35
35
36
+ // Print writes the package name and its exported interfaces.
36
37
func (pkg * Package ) Print (w io.Writer ) {
37
38
fmt .Fprintf (w , "package %s\n " , pkg .Name )
38
39
for _ , intf := range pkg .Interfaces {
@@ -55,6 +56,7 @@ type Interface struct {
55
56
Methods []* Method
56
57
}
57
58
59
+ // Print writes the interface name and its methods.
58
60
func (intf * Interface ) Print (w io.Writer ) {
59
61
fmt .Fprintf (w , "interface %s\n " , intf .Name )
60
62
for _ , m := range intf .Methods {
@@ -75,6 +77,7 @@ type Method struct {
75
77
Variadic * Parameter // may be nil
76
78
}
77
79
80
+ // Print writes the method name and its signature.
78
81
func (m * Method ) Print (w io.Writer ) {
79
82
fmt .Fprintf (w , " - method %s\n " , m .Name )
80
83
if len (m .In ) > 0 {
@@ -113,6 +116,7 @@ type Parameter struct {
113
116
Type Type
114
117
}
115
118
119
+ // Print writes a method parameter.
116
120
func (p * Parameter ) Print (w io.Writer ) {
117
121
n := p .Name
118
122
if n == "" {
@@ -183,6 +187,7 @@ func (ct *ChanType) addImports(im map[string]bool) { ct.Type.addImports(im) }
183
187
// ChanDir is a channel direction.
184
188
type ChanDir int
185
189
190
+ // Constants for channel directions.
186
191
const (
187
192
RecvDir ChanDir = 1
188
193
SendDir ChanDir = 2
@@ -255,9 +260,9 @@ func (nt *NamedType) String(pm map[string]string, pkgOverride string) string {
255
260
prefix := pm [nt .Package ]
256
261
if prefix != "" {
257
262
return prefix + "." + nt .Type
258
- } else {
259
- return nt .Type
260
263
}
264
+
265
+ return nt .Type
261
266
}
262
267
func (nt * NamedType ) addImports (im map [string ]bool ) {
263
268
if nt .Package != "" {
@@ -283,6 +288,8 @@ func (pt PredeclaredType) addImports(im map[string]bool)
283
288
284
289
// The following code is intended to be called by the program generated by ../reflect.go.
285
290
291
+ // InterfaceFromInterfaceType returns a pointer to an interface for the
292
+ // given reflection interface type.
286
293
func InterfaceFromInterfaceType (it reflect.Type ) (* Interface , error ) {
287
294
if it .Kind () != reflect .Interface {
288
295
return nil , fmt .Errorf ("%v is not an interface" , it )
0 commit comments