Skip to content

Commit bc698fa

Browse files
authored
Merge pull request #4 from chenyanchen/feat/array-starexpr-ident
Support ArrayType.StarExpr.Ident parameter type
2 parents 6aa5243 + 56a02f4 commit bc698fa

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cmd/breaker-cli/main.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,12 @@ func main() {
8484
_type = "[]" + v.Elt.(*ast.Ident).Name
8585
case *ast.StarExpr:
8686
switch x := elt.X.(type) {
87+
case *ast.Ident:
88+
_type = "[]" + "*" + packageName + "." + x.Name
8789
case *ast.SelectorExpr:
8890
_type = "[]" + "*" + x.X.(*ast.Ident).Name + "." + x.Sel.Name
8991
default:
90-
panic(fmt.Sprintf("unsupported array type: %T", elt))
92+
panic(fmt.Sprintf("unsupported array type: %T", x))
9193
}
9294
}
9395
case *ast.StarExpr:
@@ -124,6 +126,8 @@ func main() {
124126
break
125127
}
126128
_type = "..." + selectorExpr.X.(*ast.Ident).Name + "." + selectorExpr.Sel.Name
129+
case *ast.Ident:
130+
_type = v.Name
127131
default:
128132
log.Fatalf("unsupported param type: %T", field.Type)
129133
}
@@ -146,6 +150,8 @@ func main() {
146150
switch x := elt.X.(type) {
147151
case *ast.SelectorExpr:
148152
_type = "[]" + "*" + x.X.(*ast.Ident).Name + "." + x.Sel.Name
153+
case *ast.Ident:
154+
_type = "[]" + "*" + packageName + "." + x.Name
149155
default:
150156
panic(fmt.Sprintf("unsupported array type: %T", elt))
151157
}

0 commit comments

Comments
 (0)