From 921fab3913d253861ed0d50bbcac5320815093b6 Mon Sep 17 00:00:00 2001 From: Harry Li Date: Thu, 8 Aug 2024 17:46:03 +0800 Subject: [PATCH] fix(parser): handle empty theType to prevent index out of range error --- parser/class_parser.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parser/class_parser.go b/parser/class_parser.go index 9a55b93..5a7a98a 100644 --- a/parser/class_parser.go +++ b/parser/class_parser.go @@ -275,7 +275,7 @@ func (p *ClassParser) handleFuncDecl(decl *ast.FuncDecl) { // Only get in when the function is defined for a structure. Global functions are not needed for class diagram theType, _ := getFieldType(decl.Recv.List[0].Type, p.allImports) theType = replacePackageConstant(theType, "") - if theType[0] == "*"[0] { + if len(theType) > 0 && theType[0] == '*' { theType = theType[1:] } structure := p.getOrCreateStruct(theType)