gogrep icon indicating copy to clipboard operation
gogrep copied to clipboard

match constants based on value as well as syntax

Open josharian opened this issue 6 years ago • 2 comments
trafficstars

e.g. gogrep 5 should match 2+3 and also the first part of 5+7.

josharian avatar Jul 16 '19 03:07 josharian

and also, usefully, gogrep 100 should match 100 and 1_0_0. this will help one of the concerns raised near the end of golang.org/issue/28493

josharian avatar Jul 16 '19 03:07 josharian

I think the simplest way to implement this would be a command which tries its best to simplify or resolve the current expression. It would turn 2+3 into 5, pkg.One + pkg.Two into 3, concatenate strings, and so on.

Initially this would only work on constants, but it would be good if it also worked on "partial" constants. For example, nonConst * 10 * 10 could be simplified into nonConst * 100.

mvdan avatar Jul 16 '19 03:07 mvdan