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
for _, exprStmt := range m.AssignStmtList {
for _, expr := range exprStmt.Lhs {
switch v := expr.(type) {
case *ast.Ident:
//color.Blue("%v:%v \n\t[%v] %+v", meta.FullFileName,
// meta.FSet.Position(v.Pos()).Line,
// v.Name, v.Obj.Decl)
if v.Name == "err" {
color.Blue("%v:%v \n\t[%+v] %v, [type=%v]", meta.FullFileName,
meta.FSet.Position(v.Pos()).Line,
v.Obj.Type, v.Name, v.Obj.Type)
}
switch arg := v.Obj.Decl.(type) {
case *ast.Field:
color.Blue("%v:%v \n\t[%v] %v, [type=%v]", meta.FullFileName,
meta.FSet.Position(v.Pos()).Line,
arg.Type, arg.Names, v.Obj.Type)
case *ast.DeclStmt:
color.Red("XXXXXXXXXXXXXXXXXXXX")
case *ast.AssignStmt:
getIdent(meta, expr)
}
}
}
}
I want to get the variable type on the left side of assign. If it is error, then judge that name cannot be _
How can I get the variable type on the left side of assign
<!--
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
-->
### What did you expect to see?
It sure be field of the expr of assignStmt.Lhs, but no, the expr still assignStmt,
Too weird
### What did you see instead?
Get the return type of a function call
The text was updated successfully, but these errors were encountered:
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
About golang ast
The text was updated successfully, but these errors were encountered: