You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
Any use of
reflect.Value.MethodByName()
orreflect.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 callsMethodByName()
with random strings extracted from template texts.Command::UsageFunc()
andCommand::HelpFunc()
usetext/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.The text was updated successfully, but these errors were encountered: