MCPcopy
hub / github.com/vektra/mockery / varName

Function varName

template/var.go:63–84  ·  view source on GitHub ↗
(vr *types.Var, suffix string)

Source from the content-addressed store, hash-verified

61}
62
63func varName(vr *types.Var, suffix string) string {
64 name := vr.Name()
65 if name != "" && name != "_" {
66 return name + suffix
67 }
68
69 name = varNameForType(vr.Type()) + suffix
70
71 switch name {
72 case "mock", "callInfo", "break", "default", "func", "interface", "select", "case", "defer", "go", "map", "struct",
73 "chan", "else", "goto", "package", "switch", "const", "fallthrough", "if", "range", "type", "continue", "for",
74 "import", "return", "var",
75 // avoid shadowing basic types
76 "string", "bool", "byte", "rune", "uintptr",
77 "int", "int8", "int16", "int32", "int64",
78 "uint", "uint8", "uint16", "uint32", "uint64",
79 "float32", "float64", "complex64", "complex128":
80 name += "Param"
81 }
82
83 return name
84}
85
86// varNameForType generates a name for the variable using the type
87// information.

Callers 1

AddVarMethod · 0.85

Calls 3

varNameForTypeFunction · 0.85
TypeMethod · 0.80
NameMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…