`const MultiLineConst = ...`, // Multi line constant.
`var MultiLineVar = map\[struct{ ... }\]struct{ ... }{ ... }`, // Multi line variable.
`func MultiLineFunc\(x interface{ ... }\) \(r struct{ ... }\)`, // Multi line function.
+ `type T1 = T2`, // Type alias
},
[]string{
`const internalConstant = 2`, // No internal constants.
`unexportedTypedConstant`, // No unexported typed constant.
`Field`, // No fields.
`Method`, // No methods.
+ `type T1 T2`, // Type alias does not display as type declaration.
},
},
// Package dump -u
`error`, // No embedded error.
},
},
+ // Type T1 dump (alias).
+ {
+ "type T1",
+ []string{p+".T1"},
+ []string{
+ `type T1 = T2`,
+ },
+ []string{
+ `type T1 T2`,
+ `type ExportedType`,
+ },
+ },
// Type -u with unexported fields.
{
"type with unexported fields and -u",
return fmt.Sprintf("func %s%s%s", recv, name, fnc)
case *ast.TypeSpec:
- return fmt.Sprintf("type %s %s", n.Name.Name, pkg.oneLineNodeDepth(n.Type, depth))
+ sep := " "
+ if n.Assign.IsValid() {
+ sep = " = "
+ }
+ return fmt.Sprintf("type %s%s%s", n.Name.Name, sep, pkg.oneLineNodeDepth(n.Type, depth))
case *ast.FuncType:
var params []string