cmd/cloner: unify switch cases

And in the process, fix a bug:
The fmt formatting was being applied by writef,
not fmt.Sprintf, thus emitting a MISSING string.
And there's no guarantee that fmt will be imported
in the generated code.

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
Josh Bleecher Snyder 2021-09-16 16:31:35 -07:00 committed by Josh Bleecher Snyder
parent d8a8f70000
commit d5a0a4297e

View File

@ -211,10 +211,8 @@ func gen(buf *bytes.Buffer, imports map[string]struct{}, typ *types.Named, thisP
writef("\t}")
}
writef("}")
case *types.Struct:
writef(`panic("TODO struct %s")`, fname)
default:
writef(`panic(fmt.Sprintf("TODO: %T", ft))`)
writef(`panic("TODO: %s (%T)")`, fname, ft)
}
}
writef("return dst")