Closed
Description
Any use of reflect.Value.MethodByName()
or reflect.Type.MethodByName()
disables the DCE. The compiler assumes that these functions will look any method up, and cannot remove methods even if they are never called.
text/template
is a very notable offender in this respect. It calls MethodByName()
with random strings extracted from template texts.
Command::UsageFunc()
and Command::HelpFunc()
use text/template
, hence they disable the DCE for all users of cobra. Since cobra is the go-to module to implement CLIs, this essentially disables DCE in all command line tools written in go.
A low-level library that is used by almost everyone should not pessimise the code generation by disabling the DCE. I'd avoid text/template
altogether.
Metadata
Metadata
Assignees
Labels
No labels