Fix issue with custom types shadowing basic types (#163)

When a custom type has a name that can shadow an in-built type, append
MoqParam to the name. Example: var name stringMoqParam for null.String.
This commit is contained in:
dedalusj
2021-12-18 14:26:01 +11:00
committed by GitHub
parent ef8b268d53
commit 514e30653d
5 changed files with 1038 additions and 1 deletions

View File

@@ -49,7 +49,12 @@ func varName(vr *types.Var, suffix string) string {
switch name {
case "mock", "callInfo", "break", "default", "func", "interface", "select", "case", "defer", "go", "map", "struct",
"chan", "else", "goto", "package", "switch", "const", "fallthrough", "if", "range", "type", "continue", "for",
"import", "return", "var":
"import", "return", "var",
// avoid shadowing basic types
"string", "bool", "byte", "rune", "uintptr",
"int", "int8", "int16", "int32", "int64",
"uint", "uint8", "uint16", "uint32", "uint64",
"float32", "float64", "complex64", "complex128":
name += "MoqParam"
}