SelectionString returns the string form of s. The Qualifier controls the printing of package-level objects, and may be nil. Examples: "field (T) f int" "method (T) f(X) Y" "method expr (T) f(X) Y"
(s *Selection, qf Qualifier)
| 120 | // "method expr (T) f(X) Y" |
| 121 | // |
| 122 | func SelectionString(s *Selection, qf Qualifier) string { |
| 123 | var k string |
| 124 | switch s.kind { |
| 125 | case FieldVal: |
| 126 | k = "field " |
| 127 | case MethodVal: |
| 128 | k = "method " |
| 129 | case MethodExpr: |
| 130 | k = "method expr " |
| 131 | default: |
| 132 | unreachable() |
| 133 | } |
| 134 | var buf bytes.Buffer |
| 135 | buf.WriteString(k) |
| 136 | buf.WriteByte('(') |
| 137 | WriteType(&buf, s.Recv(), qf) |
| 138 | fmt.Fprintf(&buf, ") %s", s.obj.Name()) |
| 139 | if T := s.Type(); s.kind == FieldVal { |
| 140 | buf.WriteByte(' ') |
| 141 | WriteType(&buf, T, qf) |
| 142 | } else { |
| 143 | WriteSignature(&buf, T.(*Signature), qf) |
| 144 | } |
| 145 | return buf.String() |
| 146 | } |
no test coverage detected