fieldToType returns the type name and whether if it's an ellipsis.
(f *ast.Field)
| 177 | |
| 178 | // fieldToType returns the type name and whether if it's an ellipsis. |
| 179 | func fieldToType(f *ast.Field) (string, bool) { |
| 180 | switch arg := f.Type.(type) { |
| 181 | case *ast.ArrayType: |
| 182 | if arg.Len != nil { |
| 183 | // Array. |
| 184 | return "[" + name(arg.Len) + "]" + name(arg.Elt), false |
| 185 | } |
| 186 | // Slice. |
| 187 | return "[]" + name(arg.Elt), false |
| 188 | case *ast.Ellipsis: |
| 189 | return name(arg.Elt), true |
| 190 | case *ast.FuncType: |
| 191 | // Do not print the function signature to not overload the trace. |
| 192 | return "func", false |
| 193 | case *ast.Ident: |
| 194 | return arg.Name, false |
| 195 | case *ast.InterfaceType: |
| 196 | return "interface{}", false |
| 197 | case *ast.SelectorExpr: |
| 198 | return arg.Sel.Name, false |
| 199 | case *ast.StarExpr: |
| 200 | return "*" + name(arg.X), false |
| 201 | case *ast.MapType: |
| 202 | return fmt.Sprintf("map[%s]%s", name(arg.Key), name(arg.Value)), false |
| 203 | case *ast.ChanType: |
| 204 | return fmt.Sprintf("chan %s", name(arg.Value)), false |
| 205 | default: |
| 206 | // TODO(maruel): Implement anything missing. |
| 207 | return "<unknown>", false |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | // extractArgumentsType returns the name of the type of each input argument. |
| 212 | func extractArgumentsType(f *ast.FuncDecl) ([]string, bool) { |
no test coverage detected
searching dependent graphs…