Skip to content

Commit 690165e

Browse files
authored
[chore] remove space from func string representation (#740)
1 parent 6956114 commit 690165e

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

checkapi/internal/ast.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ func ExprToString(expr ast.Expr) string {
5656
if len(typeParams) > 0 {
5757
generics = fmt.Sprintf("[%s]", strings.Join(typeParams, ","))
5858
}
59+
if len(results) == 0 {
60+
return fmt.Sprintf("func%s(%s)", generics, strings.Join(params, ","))
61+
}
5962
return fmt.Sprintf("func%s(%s) %s", generics, strings.Join(params, ","), strings.Join(results, ","))
6063
case *ast.SelectorExpr:
6164
return fmt.Sprintf("%s.%s", ExprToString(e.X), e.Sel.Name)

checkapi/internal/ast_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func TestAST(t *testing.T) {
5454
{
5555
"func",
5656
&ast.FuncType{Params: &ast.FieldList{List: []*ast.Field{}}},
57-
"func() ",
57+
"func()",
5858
},
5959
{
6060
"func with params and return type",
@@ -118,7 +118,7 @@ func TestAST(t *testing.T) {
118118
Type: &ast.FuncType{Params: &ast.FieldList{List: []*ast.Field{}}},
119119
},
120120
}}},
121-
"{func func() }",
121+
"{func func()}",
122122
},
123123
{
124124
"chan",
@@ -149,7 +149,7 @@ func TestAST(t *testing.T) {
149149
},
150150
Results: nil,
151151
},
152-
"func[T ~string](T) ",
152+
"func[T ~string](T)",
153153
},
154154
}
155155

0 commit comments

Comments
 (0)