fmtDebug
fmtTypeID
fmtTypeIDName
- fmtTypeIDHash
)
// Sym
if q := pkgqual(s.Pkg, verb, mode); q != "" {
b.WriteString(q)
b.WriteByte('.')
- switch mode {
- case fmtTypeIDHash:
- // If name is a generic instantiation, don't hash the instantiating types.
- // This isn't great, but it is safe. If we hash the instantiating types, then
- // we need to make sure they have just the package name. At this point, they
- // either have "", or the whole package path, and it is hard to reconcile
- // the two without depending on -p (which we might do someday).
- // See issue 51250.
- if i := strings.Index(name, "["); i >= 0 {
- name = name[:i]
- }
- }
}
b.WriteString(name)
}
case fmtDebug:
return pkg.Name
- case fmtTypeIDName, fmtTypeIDHash:
+ case fmtTypeIDName:
// dcommontype, typehash
return pkg.Name
if t == AnyType || t == ByteType || t == RuneType {
// in %-T mode collapse predeclared aliases with their originals.
switch mode {
- case fmtTypeIDName, fmtTypeIDHash, fmtTypeID:
+ case fmtTypeIDName, fmtTypeID:
t = Types[t.Kind()]
default:
sconv2(b, t.Sym(), 'S', mode)
case TPTR:
b.WriteByte('*')
switch mode {
- case fmtTypeID, fmtTypeIDName, fmtTypeIDHash:
+ case fmtTypeID, fmtTypeIDName:
if verb == 'S' {
tconv2(b, t.Elem(), 'S', mode, visited)
return
case IsExported(f.Sym.Name):
sconv2(b, f.Sym, 'S', mode)
default:
- if mode != fmtTypeIDName && mode != fmtTypeIDHash {
+ if mode != fmtTypeIDName {
mode = fmtTypeID
}
sconv2(b, f.Sym, 'v', mode)
b.WriteByte(byte(open))
fieldVerb := 'v'
switch mode {
- case fmtTypeID, fmtTypeIDName, fmtTypeIDHash, fmtGo:
+ case fmtTypeID, fmtTypeIDName, fmtGo:
// no argument names on function signature, and no "noescape"/"nosplit" tags
fieldVerb = 'S'
}
if name == ".F" {
name = "F" // Hack for toolstash -cmp.
}
- if !IsExported(name) && mode != fmtTypeIDName && mode != fmtTypeIDHash {
+ if !IsExported(name) && mode != fmtTypeIDName {
name = sconv(s, 0, mode) // qualify non-exported names (used on structs, not on funarg)
}
} else {
// TypeHash computes a hash value for type t to use in type switch statements.
func TypeHash(t *Type) uint32 {
- p := tconv(t, 0, fmtTypeIDHash)
+ p := t.LinkString()
// Using SHA256 is overkill, but reduces accidental collisions.
h := notsha256.Sum256([]byte(p))