Improved error handling for struct types
This commit is contained in:
@ -8,7 +8,13 @@ import (
|
||||
func ByName(name string, pkg string, structs map[string]*Struct) Type {
|
||||
if strings.HasPrefix(name, "*") {
|
||||
to := strings.TrimPrefix(name, "*")
|
||||
return &Pointer{To: ByName(to, pkg, structs)}
|
||||
typ := ByName(to, pkg, structs)
|
||||
|
||||
if typ != nil {
|
||||
return &Pointer{To: typ}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
switch name {
|
||||
@ -32,5 +38,11 @@ func ByName(name string, pkg string, structs map[string]*Struct) Type {
|
||||
return PointerAny
|
||||
}
|
||||
|
||||
return structs[pkg+"."+name]
|
||||
typ, exists := structs[pkg+"."+name]
|
||||
|
||||
if !exists {
|
||||
return nil
|
||||
}
|
||||
|
||||
return typ
|
||||
}
|
||||
|
Reference in New Issue
Block a user