Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use gofumpt to format String output #4

Merged
merged 3 commits into from
Jan 2, 2021
Merged

use gofumpt to format String output #4

merged 3 commits into from
Jan 2, 2021

Conversation

slimsag
Copy link
Member

@slimsag slimsag commented Jan 2, 2021

go fmt does nothing to handle very-long-lines, of which valast will often produce due to it being a generated AST.

gofumpt is a stricter version of gofmt, which does a much better job of formatting generated code than gofmt, and has in-progress work for formatting very-long-lines.

This PR changes the default String and StringOptions output of valast to always use gofumpt formatting.

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
See mvdan/gofumpt@c49fa44

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
@slimsag
Copy link
Member Author

slimsag commented Jan 2, 2021

While the tests here show only a few readability improvements, on larger code-bases the difference is quite substantial (even without the long-line formatting yet):

diff --git a/internal/syntax/parse/testdata/TestString__comby.golden b/internal/syntax/parse/testdata/TestString__comby.golden
index 1cf1807..988df30 100644
--- a/internal/syntax/parse/testdata/TestString__comby.golden
+++ b/internal/syntax/parse/testdata/TestString__comby.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{Expr: &st.QueryExpr{CombyCode: &st.ExprCombyCode{Terms: "errorf"}}}, nil}
+[2]interface{}{&st.Query{Expr: &st.QueryExpr{CombyCode: &st.ExprCombyCode{Terms: "errorf"}}}, nil}
diff --git a/internal/syntax/parse/testdata/TestString__comby_doctypes.golden b/internal/syntax/parse/testdata/TestString__comby_doctypes.golden
index e30bdb1..19534a7 100644
--- a/internal/syntax/parse/testdata/TestString__comby_doctypes.golden
+++ b/internal/syntax/parse/testdata/TestString__comby_doctypes.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foobar"}}}, Expr: &st.QueryExpr{CombyCode: &st.ExprCombyCode{Terms: "errorf"}}}, nil}
+[2]interface{}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foobar"}}}, Expr: &st.QueryExpr{CombyCode: &st.ExprCombyCode{Terms: "errorf"}}}, nil}
diff --git a/internal/syntax/parse/testdata/TestString__comby_doctypes_invalid_options.golden b/internal/syntax/parse/testdata/TestString__comby_doctypes_invalid_options.golden
index 1a6d7dd..0d4a862 100644
--- a/internal/syntax/parse/testdata/TestString__comby_doctypes_invalid_options.golden
+++ b/internal/syntax/parse/testdata/TestString__comby_doctypes_invalid_options.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foobar"}}}}, &parse.Error{Offset: 11, Parsing: parse.NodeType(parse.NodeType)("OptionsCombyCode"), Message: ": valid options are (delimiter), found case"}}
+[2]interface{}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foobar"}}}}, &parse.Error{Offset: 11, Parsing: parse.NodeType(parse.NodeType)("OptionsCombyCode"), Message: ": valid options are (delimiter), found case"}}
diff --git a/internal/syntax/parse/testdata/TestString__comby_invalid_options.golden b/internal/syntax/parse/testdata/TestString__comby_invalid_options.golden
index 9aec439..dcc8c2a 100644
--- a/internal/syntax/parse/testdata/TestString__comby_invalid_options.golden
+++ b/internal/syntax/parse/testdata/TestString__comby_invalid_options.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{}, &parse.Error{Offset: 4, Parsing: parse.NodeType(parse.NodeType)("OptionsCombyCode"), Message: ": valid options are (delimiter), found case"}}
+[2]interface{}{&st.Query{}, &parse.Error{Offset: 4, Parsing: parse.NodeType(parse.NodeType)("OptionsCombyCode"), Message: ": valid options are (delimiter), found case"}}
diff --git a/internal/syntax/parse/testdata/TestString__comby_options.golden b/internal/syntax/parse/testdata/TestString__comby_options.golden
index 4fde08d..6ef1865 100644
--- a/internal/syntax/parse/testdata/TestString__comby_options.golden
+++ b/internal/syntax/parse/testdata/TestString__comby_options.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{}, &parse.Error{Offset: 13, Parsing: parse.NodeType(parse.NodeType)("OptionsFuzzy"), Message: ": valid options are (multiline, case), found delimiter"}}
+[2]interface{}{&st.Query{}, &parse.Error{Offset: 13, Parsing: parse.NodeType(parse.NodeType)("OptionsFuzzy"), Message: ": valid options are (multiline, case), found delimiter"}}
diff --git a/internal/syntax/parse/testdata/TestString__default.golden b/internal/syntax/parse/testdata/TestString__default.golden
index e362059..a7f7380 100644
--- a/internal/syntax/parse/testdata/TestString__default.golden
+++ b/internal/syntax/parse/testdata/TestString__default.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{}, &parse.Error{Offset: 6, Parsing: parse.NodeType(parse.NodeType)("OptionsFuzzy"), Message: ": valid options are (multiline, case), found errorf"}}
+[2]interface{}{&st.Query{}, &parse.Error{Offset: 6, Parsing: parse.NodeType(parse.NodeType)("OptionsFuzzy"), Message: ": valid options are (multiline, case), found errorf"}}
diff --git a/internal/syntax/parse/testdata/TestString__default_doctypes.golden b/internal/syntax/parse/testdata/TestString__default_doctypes.golden
index ac49366..ac5bdea 100644
--- a/internal/syntax/parse/testdata/TestString__default_doctypes.golden
+++ b/internal/syntax/parse/testdata/TestString__default_doctypes.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foobar"}}}, Expr: &st.QueryExpr{Default: &st.ExprDefault{Question: true, Terms: "errorf"}}}, nil}
+[2]interface{}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foobar"}}}, Expr: &st.QueryExpr{Default: &st.ExprDefault{Question: true, Terms: "errorf"}}}, nil}
diff --git a/internal/syntax/parse/testdata/TestString__default_doctypes_multiple_options.golden b/internal/syntax/parse/testdata/TestString__default_doctypes_multiple_options.golden
index 5e46526..bea9303 100644
--- a/internal/syntax/parse/testdata/TestString__default_doctypes_multiple_options.golden
+++ b/internal/syntax/parse/testdata/TestString__default_doctypes_multiple_options.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foobar"}}}}, &parse.Error{Offset: 25, Parsing: parse.NodeType(parse.NodeType)("OptionsLiteral"), Message: ": valid options are (wholeline, case), found multiline"}}
+[2]interface{}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foobar"}}}}, &parse.Error{Offset: 25, Parsing: parse.NodeType(parse.NodeType)("OptionsLiteral"), Message: ": valid options are (wholeline, case), found multiline"}}
diff --git a/internal/syntax/parse/testdata/TestString__default_doctypes_options.golden b/internal/syntax/parse/testdata/TestString__default_doctypes_options.golden
index 1a6d7dd..0d4a862 100644
--- a/internal/syntax/parse/testdata/TestString__default_doctypes_options.golden
+++ b/internal/syntax/parse/testdata/TestString__default_doctypes_options.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foobar"}}}}, &parse.Error{Offset: 11, Parsing: parse.NodeType(parse.NodeType)("OptionsCombyCode"), Message: ": valid options are (delimiter), found case"}}
+[2]interface{}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foobar"}}}}, &parse.Error{Offset: 11, Parsing: parse.NodeType(parse.NodeType)("OptionsCombyCode"), Message: ": valid options are (delimiter), found case"}}
diff --git a/internal/syntax/parse/testdata/TestString__default_options.golden b/internal/syntax/parse/testdata/TestString__default_options.golden
index 9aec439..dcc8c2a 100644
--- a/internal/syntax/parse/testdata/TestString__default_options.golden
+++ b/internal/syntax/parse/testdata/TestString__default_options.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{}, &parse.Error{Offset: 4, Parsing: parse.NodeType(parse.NodeType)("OptionsCombyCode"), Message: ": valid options are (delimiter), found case"}}
+[2]interface{}{&st.Query{}, &parse.Error{Offset: 4, Parsing: parse.NodeType(parse.NodeType)("OptionsCombyCode"), Message: ": valid options are (delimiter), found case"}}
diff --git a/internal/syntax/parse/testdata/TestString__empty_string.golden b/internal/syntax/parse/testdata/TestString__empty_string.golden
index bba7092..6103c6d 100644
--- a/internal/syntax/parse/testdata/TestString__empty_string.golden
+++ b/internal/syntax/parse/testdata/TestString__empty_string.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{Expr: &st.QueryExpr{Default: &st.ExprDefault{}}}, nil}
+[2]interface{}{&st.Query{Expr: &st.QueryExpr{Default: &st.ExprDefault{}}}, nil}
diff --git a/internal/syntax/parse/testdata/TestString__fuzzy.golden b/internal/syntax/parse/testdata/TestString__fuzzy.golden
index ae43348..0fede0e 100644
--- a/internal/syntax/parse/testdata/TestString__fuzzy.golden
+++ b/internal/syntax/parse/testdata/TestString__fuzzy.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{Expr: &st.QueryExpr{Fuzzy: &st.ExprFuzzy{Terms: "errorf"}}}, nil}
+[2]interface{}{&st.Query{Expr: &st.QueryExpr{Fuzzy: &st.ExprFuzzy{Terms: "errorf"}}}, nil}
diff --git a/internal/syntax/parse/testdata/TestString__fuzzy_doctypes.golden b/internal/syntax/parse/testdata/TestString__fuzzy_doctypes.golden
index ea692a5..fff2a9b 100644
--- a/internal/syntax/parse/testdata/TestString__fuzzy_doctypes.golden
+++ b/internal/syntax/parse/testdata/TestString__fuzzy_doctypes.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foo", Separator: ",", Next: &st.DocTypesListCST{Name: "bar"}}}}, Expr: &st.QueryExpr{Fuzzy: &st.ExprFuzzy{Terms: "errorf"}}}, nil}
+[2]interface{}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foo", Separator: ",", Next: &st.DocTypesListCST{Name: "bar"}}}}, Expr: &st.QueryExpr{Fuzzy: &st.ExprFuzzy{Terms: "errorf"}}}, nil}
diff --git a/internal/syntax/parse/testdata/TestString__fuzzy_doctypes_invalid_options.golden b/internal/syntax/parse/testdata/TestString__fuzzy_doctypes_invalid_options.golden
index 4074b4d..733fcb3 100644
--- a/internal/syntax/parse/testdata/TestString__fuzzy_doctypes_invalid_options.golden
+++ b/internal/syntax/parse/testdata/TestString__fuzzy_doctypes_invalid_options.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foobar"}}}}, &parse.Error{Offset: 15, Parsing: parse.NodeType(parse.NodeType)("OptionsFuzzy"), Message: ": valid options are (multiline, case), found notvalid"}}
+[2]interface{}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foobar"}}}}, &parse.Error{Offset: 15, Parsing: parse.NodeType(parse.NodeType)("OptionsFuzzy"), Message: ": valid options are (multiline, case), found notvalid"}}
diff --git a/internal/syntax/parse/testdata/TestString__fuzzy_doctypes_options.golden b/internal/syntax/parse/testdata/TestString__fuzzy_doctypes_options.golden
index d587566..0333da4 100644
--- a/internal/syntax/parse/testdata/TestString__fuzzy_doctypes_options.golden
+++ b/internal/syntax/parse/testdata/TestString__fuzzy_doctypes_options.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foo", Separator: ",", Next: &st.DocTypesListCST{Name: "bar"}}}}, Expr: &st.QueryExpr{Fuzzy: &st.ExprFuzzy{Options: &st.OptionsFuzzy{Options: st.Options{CST: &st.OptionsCST{Option: &st.Option{Key: "multiline"}, Separator: ",", Next: &st.OptionsCST{Option: &st.Option{Key: "case"}}}}}, Terms: "errorf"}}}, nil}
+[2]interface{}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foo", Separator: ",", Next: &st.DocTypesListCST{Name: "bar"}}}}, Expr: &st.QueryExpr{Fuzzy: &st.ExprFuzzy{Options: &st.OptionsFuzzy{Options: st.Options{CST: &st.OptionsCST{Option: &st.Option{Key: "multiline"}, Separator: ",", Next: &st.OptionsCST{Option: &st.Option{Key: "case"}}}}}, Terms: "errorf"}}}, nil}
diff --git a/internal/syntax/parse/testdata/TestString__fuzzy_options.golden b/internal/syntax/parse/testdata/TestString__fuzzy_options.golden
index 0365bba..9585f6c 100644
--- a/internal/syntax/parse/testdata/TestString__fuzzy_options.golden
+++ b/internal/syntax/parse/testdata/TestString__fuzzy_options.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{Expr: &st.QueryExpr{Fuzzy: &st.ExprFuzzy{Options: &st.OptionsFuzzy{Options: st.Options{CST: &st.OptionsCST{Option: &st.Option{Key: "multiline"}, Separator: ",", Next: &st.OptionsCST{Option: &st.Option{Key: "case"}}}}}, Terms: "errorf"}}}, nil}
+[2]interface{}{&st.Query{Expr: &st.QueryExpr{Fuzzy: &st.ExprFuzzy{Options: &st.OptionsFuzzy{Options: st.Options{CST: &st.OptionsCST{Option: &st.Option{Key: "multiline"}, Separator: ",", Next: &st.OptionsCST{Option: &st.Option{Key: "case"}}}}}, Terms: "errorf"}}}, nil}
diff --git a/internal/syntax/parse/testdata/TestString__literal.golden b/internal/syntax/parse/testdata/TestString__literal.golden
index 4f48883..643b004 100644
--- a/internal/syntax/parse/testdata/TestString__literal.golden
+++ b/internal/syntax/parse/testdata/TestString__literal.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{Expr: &st.QueryExpr{Literal: &st.ExprLiteral{Terms: "errorf"}}}, nil}
+[2]interface{}{&st.Query{Expr: &st.QueryExpr{Literal: &st.ExprLiteral{Terms: "errorf"}}}, nil}
diff --git a/internal/syntax/parse/testdata/TestString__literal_doctypes.golden b/internal/syntax/parse/testdata/TestString__literal_doctypes.golden
index e64ec5a..65e32e8 100644
--- a/internal/syntax/parse/testdata/TestString__literal_doctypes.golden
+++ b/internal/syntax/parse/testdata/TestString__literal_doctypes.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foo", Separator: ",", Next: &st.DocTypesListCST{Name: "bar"}}}}, Expr: &st.QueryExpr{Literal: &st.ExprLiteral{Terms: "errorf"}}}, nil}
+[2]interface{}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foo", Separator: ",", Next: &st.DocTypesListCST{Name: "bar"}}}}, Expr: &st.QueryExpr{Literal: &st.ExprLiteral{Terms: "errorf"}}}, nil}
diff --git a/internal/syntax/parse/testdata/TestString__literal_doctypes_invalid_options.golden b/internal/syntax/parse/testdata/TestString__literal_doctypes_invalid_options.golden
index 4074b4d..733fcb3 100644
--- a/internal/syntax/parse/testdata/TestString__literal_doctypes_invalid_options.golden
+++ b/internal/syntax/parse/testdata/TestString__literal_doctypes_invalid_options.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foobar"}}}}, &parse.Error{Offset: 15, Parsing: parse.NodeType(parse.NodeType)("OptionsFuzzy"), Message: ": valid options are (multiline, case), found notvalid"}}
+[2]interface{}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foobar"}}}}, &parse.Error{Offset: 15, Parsing: parse.NodeType(parse.NodeType)("OptionsFuzzy"), Message: ": valid options are (multiline, case), found notvalid"}}
diff --git a/internal/syntax/parse/testdata/TestString__literal_doctypes_options.golden b/internal/syntax/parse/testdata/TestString__literal_doctypes_options.golden
index f4e976c..b8bb0ab 100644
--- a/internal/syntax/parse/testdata/TestString__literal_doctypes_options.golden
+++ b/internal/syntax/parse/testdata/TestString__literal_doctypes_options.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foo", Separator: ",", Next: &st.DocTypesListCST{Name: "bar"}}}}}, &parse.Error{Offset: 22, Parsing: parse.NodeType(parse.NodeType)("OptionsFuzzy"), Message: ": valid options are (multiline, case), found wholeline"}}
+[2]interface{}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foo", Separator: ",", Next: &st.DocTypesListCST{Name: "bar"}}}}}, &parse.Error{Offset: 22, Parsing: parse.NodeType(parse.NodeType)("OptionsFuzzy"), Message: ": valid options are (multiline, case), found wholeline"}}
diff --git a/internal/syntax/parse/testdata/TestString__literal_options.golden b/internal/syntax/parse/testdata/TestString__literal_options.golden
index 6178019..fba4a4a 100644
--- a/internal/syntax/parse/testdata/TestString__literal_options.golden
+++ b/internal/syntax/parse/testdata/TestString__literal_options.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{}, &parse.Error{Offset: 14, Parsing: parse.NodeType(parse.NodeType)("OptionsFuzzy"), Message: ": valid options are (multiline, case), found wholeline"}}
+[2]interface{}{&st.Query{}, &parse.Error{Offset: 14, Parsing: parse.NodeType(parse.NodeType)("OptionsFuzzy"), Message: ": valid options are (multiline, case), found wholeline"}}
diff --git a/internal/syntax/parse/testdata/TestString__logical_and.golden b/internal/syntax/parse/testdata/TestString__logical_and.golden
index aba9940..b17e83a 100644
--- a/internal/syntax/parse/testdata/TestString__logical_and.golden
+++ b/internal/syntax/parse/testdata/TestString__logical_and.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{Expr: &st.QueryExpr{Logical: &st.ExprLogical{And: &st.ExprLogicalAnd{Left: st.QueryExpr{Default: &st.ExprDefault{Terms: "not implemented"}}, Right: st.QueryExpr{Default: &st.ExprDefault{Terms: "not implemented"}}}}}}, nil}
+[2]interface{}{&st.Query{Expr: &st.QueryExpr{Logical: &st.ExprLogical{And: &st.ExprLogicalAnd{Left: st.QueryExpr{Default: &st.ExprDefault{Terms: "not implemented"}}, Right: st.QueryExpr{Default: &st.ExprDefault{Terms: "not implemented"}}}}}}, nil}
diff --git a/internal/syntax/parse/testdata/TestString__logical_and_not.golden b/internal/syntax/parse/testdata/TestString__logical_and_not.golden
index 9cad835..55745ca 100644
--- a/internal/syntax/parse/testdata/TestString__logical_and_not.golden
+++ b/internal/syntax/parse/testdata/TestString__logical_and_not.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{Expr: &st.QueryExpr{Logical: &st.ExprLogical{AndNot: &st.ExprLogicalAndNot{Left: st.QueryExpr{Default: &st.ExprDefault{Terms: "not implemented"}}, Right: st.QueryExpr{Default: &st.ExprDefault{Terms: "not implemented"}}}}}}, nil}
+[2]interface{}{&st.Query{Expr: &st.QueryExpr{Logical: &st.ExprLogical{AndNot: &st.ExprLogicalAndNot{Left: st.QueryExpr{Default: &st.ExprDefault{Terms: "not implemented"}}, Right: st.QueryExpr{Default: &st.ExprDefault{Terms: "not implemented"}}}}}}, nil}
diff --git a/internal/syntax/parse/testdata/TestString__logical_doctypes.golden b/internal/syntax/parse/testdata/TestString__logical_doctypes.golden
index 5218b41..92d51df 100644
--- a/internal/syntax/parse/testdata/TestString__logical_doctypes.golden
+++ b/internal/syntax/parse/testdata/TestString__logical_doctypes.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foo", Separator: ",", Next: &st.DocTypesListCST{Name: "bar"}}}}, Expr: &st.QueryExpr{Logical: &st.ExprLogical{Or: &st.ExprLogicalOr{Left: st.QueryExpr{Default: &st.ExprDefault{Terms: "not implemented"}}, Right: st.QueryExpr{Default: &st.ExprDefault{Terms: "not implemented"}}}}}}, nil}
+[2]interface{}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foo", Separator: ",", Next: &st.DocTypesListCST{Name: "bar"}}}}, Expr: &st.QueryExpr{Logical: &st.ExprLogical{Or: &st.ExprLogicalOr{Left: st.QueryExpr{Default: &st.ExprDefault{Terms: "not implemented"}}, Right: st.QueryExpr{Default: &st.ExprDefault{Terms: "not implemented"}}}}}}, nil}
diff --git a/internal/syntax/parse/testdata/TestString__logical_doctypes_invalid_options.golden b/internal/syntax/parse/testdata/TestString__logical_doctypes_invalid_options.golden
index f4e976c..b8bb0ab 100644
--- a/internal/syntax/parse/testdata/TestString__logical_doctypes_invalid_options.golden
+++ b/internal/syntax/parse/testdata/TestString__logical_doctypes_invalid_options.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foo", Separator: ",", Next: &st.DocTypesListCST{Name: "bar"}}}}}, &parse.Error{Offset: 22, Parsing: parse.NodeType(parse.NodeType)("OptionsFuzzy"), Message: ": valid options are (multiline, case), found wholeline"}}
+[2]interface{}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foo", Separator: ",", Next: &st.DocTypesListCST{Name: "bar"}}}}}, &parse.Error{Offset: 22, Parsing: parse.NodeType(parse.NodeType)("OptionsFuzzy"), Message: ": valid options are (multiline, case), found wholeline"}}
diff --git a/internal/syntax/parse/testdata/TestString__logical_error.golden b/internal/syntax/parse/testdata/TestString__logical_error.golden
index 3310167..7c3c707 100644
--- a/internal/syntax/parse/testdata/TestString__logical_error.golden
+++ b/internal/syntax/parse/testdata/TestString__logical_error.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{Expr: &st.QueryExpr{Default: &st.ExprDefault{Terms: "(errorf)"}}}, nil}
+[2]interface{}{&st.Query{Expr: &st.QueryExpr{Default: &st.ExprDefault{Terms: "(errorf)"}}}, nil}
diff --git a/internal/syntax/parse/testdata/TestString__logical_invalid_options.golden b/internal/syntax/parse/testdata/TestString__logical_invalid_options.golden
index 6178019..fba4a4a 100644
--- a/internal/syntax/parse/testdata/TestString__logical_invalid_options.golden
+++ b/internal/syntax/parse/testdata/TestString__logical_invalid_options.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{}, &parse.Error{Offset: 14, Parsing: parse.NodeType(parse.NodeType)("OptionsFuzzy"), Message: ": valid options are (multiline, case), found wholeline"}}
+[2]interface{}{&st.Query{}, &parse.Error{Offset: 14, Parsing: parse.NodeType(parse.NodeType)("OptionsFuzzy"), Message: ": valid options are (multiline, case), found wholeline"}}
diff --git a/internal/syntax/parse/testdata/TestString__logical_or.golden b/internal/syntax/parse/testdata/TestString__logical_or.golden
index be3a82d..4c2f812 100644
--- a/internal/syntax/parse/testdata/TestString__logical_or.golden
+++ b/internal/syntax/parse/testdata/TestString__logical_or.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{Expr: &st.QueryExpr{Logical: &st.ExprLogical{Or: &st.ExprLogicalOr{Left: st.QueryExpr{Default: &st.ExprDefault{Terms: "not implemented"}}, Right: st.QueryExpr{Default: &st.ExprDefault{Terms: "not implemented"}}}}}}, nil}
+[2]interface{}{&st.Query{Expr: &st.QueryExpr{Logical: &st.ExprLogical{Or: &st.ExprLogicalOr{Left: st.QueryExpr{Default: &st.ExprDefault{Terms: "not implemented"}}, Right: st.QueryExpr{Default: &st.ExprDefault{Terms: "not implemented"}}}}}}, nil}
diff --git a/internal/syntax/parse/testdata/TestString__metadata.golden b/internal/syntax/parse/testdata/TestString__metadata.golden
index 893d8f9..ce58694 100644
--- a/internal/syntax/parse/testdata/TestString__metadata.golden
+++ b/internal/syntax/parse/testdata/TestString__metadata.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{Expr: &st.QueryExpr{Metadata: &st.ExprMetadata{Terms: "errorf"}}}, nil}
+[2]interface{}{&st.Query{Expr: &st.QueryExpr{Metadata: &st.ExprMetadata{Terms: "errorf"}}}, nil}
diff --git a/internal/syntax/parse/testdata/TestString__metadata_doctypes.golden b/internal/syntax/parse/testdata/TestString__metadata_doctypes.golden
index df0318a..996a4b1 100644
--- a/internal/syntax/parse/testdata/TestString__metadata_doctypes.golden
+++ b/internal/syntax/parse/testdata/TestString__metadata_doctypes.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foo", Separator: ",", Next: &st.DocTypesListCST{Name: "bar"}}}}, Expr: &st.QueryExpr{Metadata: &st.ExprMetadata{Terms: "errorf"}}}, nil}
+[2]interface{}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foo", Separator: ",", Next: &st.DocTypesListCST{Name: "bar"}}}}, Expr: &st.QueryExpr{Metadata: &st.ExprMetadata{Terms: "errorf"}}}, nil}
diff --git a/internal/syntax/parse/testdata/TestString__metadata_doctypes_invalid_options.golden b/internal/syntax/parse/testdata/TestString__metadata_doctypes_invalid_options.golden
index f4e976c..b8bb0ab 100644
--- a/internal/syntax/parse/testdata/TestString__metadata_doctypes_invalid_options.golden
+++ b/internal/syntax/parse/testdata/TestString__metadata_doctypes_invalid_options.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foo", Separator: ",", Next: &st.DocTypesListCST{Name: "bar"}}}}}, &parse.Error{Offset: 22, Parsing: parse.NodeType(parse.NodeType)("OptionsFuzzy"), Message: ": valid options are (multiline, case), found wholeline"}}
+[2]interface{}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foo", Separator: ",", Next: &st.DocTypesListCST{Name: "bar"}}}}}, &parse.Error{Offset: 22, Parsing: parse.NodeType(parse.NodeType)("OptionsFuzzy"), Message: ": valid options are (multiline, case), found wholeline"}}
diff --git a/internal/syntax/parse/testdata/TestString__metadata_invalid_options.golden b/internal/syntax/parse/testdata/TestString__metadata_invalid_options.golden
index 6178019..fba4a4a 100644
--- a/internal/syntax/parse/testdata/TestString__metadata_invalid_options.golden
+++ b/internal/syntax/parse/testdata/TestString__metadata_invalid_options.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{}, &parse.Error{Offset: 14, Parsing: parse.NodeType(parse.NodeType)("OptionsFuzzy"), Message: ": valid options are (multiline, case), found wholeline"}}
+[2]interface{}{&st.Query{}, &parse.Error{Offset: 14, Parsing: parse.NodeType(parse.NodeType)("OptionsFuzzy"), Message: ": valid options are (multiline, case), found wholeline"}}
diff --git a/internal/syntax/parse/testdata/TestString__regex.golden b/internal/syntax/parse/testdata/TestString__regex.golden
index 1219a1e..6ef4524 100644
--- a/internal/syntax/parse/testdata/TestString__regex.golden
+++ b/internal/syntax/parse/testdata/TestString__regex.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{Expr: &st.QueryExpr{Regex: &st.ExprRegex{Terms: "errorf"}}}, nil}
+[2]interface{}{&st.Query{Expr: &st.QueryExpr{Regex: &st.ExprRegex{Terms: "errorf"}}}, nil}
diff --git a/internal/syntax/parse/testdata/TestString__regex_doctypes.golden b/internal/syntax/parse/testdata/TestString__regex_doctypes.golden
index e221dcc..3c8fa4d 100644
--- a/internal/syntax/parse/testdata/TestString__regex_doctypes.golden
+++ b/internal/syntax/parse/testdata/TestString__regex_doctypes.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foo", Separator: ",", Next: &st.DocTypesListCST{Name: "bar"}}}}, Expr: &st.QueryExpr{Regex: &st.ExprRegex{Terms: "errorf"}}}, nil}
+[2]interface{}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foo", Separator: ",", Next: &st.DocTypesListCST{Name: "bar"}}}}, Expr: &st.QueryExpr{Regex: &st.ExprRegex{Terms: "errorf"}}}, nil}
diff --git a/internal/syntax/parse/testdata/TestString__regex_doctypes_invalid_options.golden b/internal/syntax/parse/testdata/TestString__regex_doctypes_invalid_options.golden
index 4074b4d..733fcb3 100644
--- a/internal/syntax/parse/testdata/TestString__regex_doctypes_invalid_options.golden
+++ b/internal/syntax/parse/testdata/TestString__regex_doctypes_invalid_options.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foobar"}}}}, &parse.Error{Offset: 15, Parsing: parse.NodeType(parse.NodeType)("OptionsFuzzy"), Message: ": valid options are (multiline, case), found notvalid"}}
+[2]interface{}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foobar"}}}}, &parse.Error{Offset: 15, Parsing: parse.NodeType(parse.NodeType)("OptionsFuzzy"), Message: ": valid options are (multiline, case), found notvalid"}}
diff --git a/internal/syntax/parse/testdata/TestString__regex_doctypes_options.golden b/internal/syntax/parse/testdata/TestString__regex_doctypes_options.golden
index e45f811..8e535e7 100644
--- a/internal/syntax/parse/testdata/TestString__regex_doctypes_options.golden
+++ b/internal/syntax/parse/testdata/TestString__regex_doctypes_options.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foo", Separator: ",", Next: &st.DocTypesListCST{Name: "bar"}}}}}, &parse.Error{Offset: 22, Parsing: parse.NodeType(parse.NodeType)("OptionsLiteral"), Message: ": valid options are (wholeline, case), found multiline"}}
+[2]interface{}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foo", Separator: ",", Next: &st.DocTypesListCST{Name: "bar"}}}}}, &parse.Error{Offset: 22, Parsing: parse.NodeType(parse.NodeType)("OptionsLiteral"), Message: ": valid options are (wholeline, case), found multiline"}}
diff --git a/internal/syntax/parse/testdata/TestString__regex_options.golden b/internal/syntax/parse/testdata/TestString__regex_options.golden
index f146f75..f9c3dbf 100644
--- a/internal/syntax/parse/testdata/TestString__regex_options.golden
+++ b/internal/syntax/parse/testdata/TestString__regex_options.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{}, &parse.Error{Offset: 14, Parsing: parse.NodeType(parse.NodeType)("OptionsLiteral"), Message: ": valid options are (wholeline, case), found multiline"}}
+[2]interface{}{&st.Query{}, &parse.Error{Offset: 14, Parsing: parse.NodeType(parse.NodeType)("OptionsLiteral"), Message: ": valid options are (wholeline, case), found multiline"}}
diff --git a/internal/syntax/parse/testdata/TestString__tristruct.golden b/internal/syntax/parse/testdata/TestString__tristruct.golden
index 49cb168..2273877 100644
--- a/internal/syntax/parse/testdata/TestString__tristruct.golden
+++ b/internal/syntax/parse/testdata/TestString__tristruct.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{Expr: &st.QueryExpr{Tristruct: &st.ExprTristruct{Terms: "errorf"}}}, nil}
+[2]interface{}{&st.Query{Expr: &st.QueryExpr{Tristruct: &st.ExprTristruct{Terms: "errorf"}}}, nil}
diff --git a/internal/syntax/parse/testdata/TestString__tristruct_doctypes.golden b/internal/syntax/parse/testdata/TestString__tristruct_doctypes.golden
index 84eb986..bd508a5 100644
--- a/internal/syntax/parse/testdata/TestString__tristruct_doctypes.golden
+++ b/internal/syntax/parse/testdata/TestString__tristruct_doctypes.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foo", Separator: ",", Next: &st.DocTypesListCST{Name: "bar"}}}}, Expr: &st.QueryExpr{Tristruct: &st.ExprTristruct{Terms: "errorf"}}}, nil}
+[2]interface{}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foo", Separator: ",", Next: &st.DocTypesListCST{Name: "bar"}}}}, Expr: &st.QueryExpr{Tristruct: &st.ExprTristruct{Terms: "errorf"}}}, nil}
diff --git a/internal/syntax/parse/testdata/TestString__tristruct_doctypes_invalid_options#01.golden b/internal/syntax/parse/testdata/TestString__tristruct_doctypes_invalid_options#01.golden
index 4074b4d..733fcb3 100644
--- a/internal/syntax/parse/testdata/TestString__tristruct_doctypes_invalid_options#01.golden
+++ b/internal/syntax/parse/testdata/TestString__tristruct_doctypes_invalid_options#01.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foobar"}}}}, &parse.Error{Offset: 15, Parsing: parse.NodeType(parse.NodeType)("OptionsFuzzy"), Message: ": valid options are (multiline, case), found notvalid"}}
+[2]interface{}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foobar"}}}}, &parse.Error{Offset: 15, Parsing: parse.NodeType(parse.NodeType)("OptionsFuzzy"), Message: ": valid options are (multiline, case), found notvalid"}}
diff --git a/internal/syntax/parse/testdata/TestString__tristruct_doctypes_invalid_options.golden b/internal/syntax/parse/testdata/TestString__tristruct_doctypes_invalid_options.golden
index e45f811..8e535e7 100644
--- a/internal/syntax/parse/testdata/TestString__tristruct_doctypes_invalid_options.golden
+++ b/internal/syntax/parse/testdata/TestString__tristruct_doctypes_invalid_options.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foo", Separator: ",", Next: &st.DocTypesListCST{Name: "bar"}}}}}, &parse.Error{Offset: 22, Parsing: parse.NodeType(parse.NodeType)("OptionsLiteral"), Message: ": valid options are (wholeline, case), found multiline"}}
+[2]interface{}{&st.Query{DocTypes: &st.DocTypes{CST: &st.DocTypesCST{List: &st.DocTypesListCST{Name: "foo", Separator: ",", Next: &st.DocTypesListCST{Name: "bar"}}}}}, &parse.Error{Offset: 22, Parsing: parse.NodeType(parse.NodeType)("OptionsLiteral"), Message: ": valid options are (wholeline, case), found multiline"}}
diff --git a/internal/syntax/parse/testdata/TestString__tristruct_invalid_options.golden b/internal/syntax/parse/testdata/TestString__tristruct_invalid_options.golden
index f146f75..f9c3dbf 100644
--- a/internal/syntax/parse/testdata/TestString__tristruct_invalid_options.golden
+++ b/internal/syntax/parse/testdata/TestString__tristruct_invalid_options.golden
@@ -1,2 +1 @@
-[2]interface {
-}{&st.Query{}, &parse.Error{Offset: 14, Parsing: parse.NodeType(parse.NodeType)("OptionsLiteral"), Message: ": valid options are (wholeline, case), found multiline"}}
+[2]interface{}{&st.Query{}, &parse.Error{Offset: 14, Parsing: parse.NodeType(parse.NodeType)("OptionsLiteral"), Message: ": valid options are (wholeline, case), found multiline"}}

@slimsag slimsag merged commit f98290c into main Jan 2, 2021
@slimsag slimsag deleted the sg/use-gofumpt branch January 2, 2021 14:37
slimsag added a commit that referenced this pull request Feb 18, 2021
With complex data types, this can provide a 66% performance improvement.

Before:

```
$ go test -bench=.
goos: darwin
goarch: amd64
pkg: github.com/hexops/valast
BenchmarkComplexType-16    	       2	 564812395 ns/op
PASS
ok  	github.com/hexops/valast	9.372s
```

After:

```
$ go test -bench=.
goos: darwin
goarch: amd64
pkg: github.com/hexops/valast
BenchmarkComplexType-16    	       6	 189646854 ns/op
PASS
ok  	github.com/hexops/valast	6.379s
```

In practice this can result in tests running much faster, before:

```
--- PASS: TestUnionMerge (6.38s)
    --- PASS: TestUnionMerge/#00 (1.42s)
    --- PASS: TestUnionMerge/#1 (1.17s)
    --- PASS: TestUnionMerge/#2 (2.32s)
    --- PASS: TestUnionMerge/#3 (0.00s)
    --- PASS: TestUnionMerge/#4 (0.00s)
    --- PASS: TestUnionMerge/#5 (1.46s)
```

After:

```
--- PASS: TestUnionMerge (2.96s)
    --- PASS: TestUnionMerge/#00 (1.05s)
    --- PASS: TestUnionMerge/#1 (0.77s)
    --- PASS: TestUnionMerge/#2 (0.77s)
    --- PASS: TestUnionMerge/#3 (0.00s)
    --- PASS: TestUnionMerge/#4 (0.00s)
    --- PASS: TestUnionMerge/#5 (0.37s)
```

Also appears to fix hexops/autogold#16

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
slimsag added a commit that referenced this pull request Feb 18, 2021
With complex data types, this can provide a 66% performance improvement.

Before:

```
$ go test -bench=.
goos: darwin
goarch: amd64
pkg: github.com/hexops/valast
BenchmarkComplexType-16    	       2	 564812395 ns/op
PASS
ok  	github.com/hexops/valast	9.372s
```

After:

```
$ go test -bench=.
goos: darwin
goarch: amd64
pkg: github.com/hexops/valast
BenchmarkComplexType-16    	       6	 189646854 ns/op
PASS
ok  	github.com/hexops/valast	6.379s
```

In practice this can result in tests running much faster, before:

```
--- PASS: TestUnionMerge (6.38s)
    --- PASS: TestUnionMerge/#00 (1.42s)
    --- PASS: TestUnionMerge/#1 (1.17s)
    --- PASS: TestUnionMerge/#2 (2.32s)
    --- PASS: TestUnionMerge/#3 (0.00s)
    --- PASS: TestUnionMerge/#4 (0.00s)
    --- PASS: TestUnionMerge/#5 (1.46s)
```

After:

```
--- PASS: TestUnionMerge (2.96s)
    --- PASS: TestUnionMerge/#00 (1.05s)
    --- PASS: TestUnionMerge/#1 (0.77s)
    --- PASS: TestUnionMerge/#2 (0.77s)
    --- PASS: TestUnionMerge/#3 (0.00s)
    --- PASS: TestUnionMerge/#4 (0.00s)
    --- PASS: TestUnionMerge/#5 (0.37s)
```

Also appears to fix hexops/autogold#16

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant