Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: runtime error: index out of range #161

Open
j1elo opened this issue Oct 9, 2023 · 1 comment
Open

panic: runtime error: index out of range #161

j1elo opened this issue Oct 9, 2023 · 1 comment

Comments

@j1elo
Copy link

j1elo commented Oct 9, 2023

I'm afraid I found a runtime panic while trying to run with https://github.com/livekit/livekit. Hopefully this helps with improving goplantuml's parser.

Curiously, the web version worked fine for me: https://www.dumels.com/diagram/9409c9a6-9f34-4cdb-a15f-fd6256fb4019

But I'd like to also be able to run it locally.

Commands:

go get github.com/jfeliu007/goplantuml/parser
go install github.com/jfeliu007/goplantuml/cmd/goplantuml@latest
git clone https://github.com/livekit/livekit.git
cd livekit/
goplantuml -recursive .

Output:

panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/jfeliu007/goplantuml/parser.(*Struct).AddField(0xc0002ef1f0, 0xc0002b6180, 0xc00020d278?)
        /home/work/golang/pkg/mod/github.com/jfeliu007/[email protected]/parser/struct.go:99 +0x270
github.com/jfeliu007/goplantuml/parser.handleGenDecStructType(0xc0000b80f0, {0xc00020d278, 0x11}, 0x18?)
        /home/work/golang/pkg/mod/github.com/jfeliu007/[email protected]/parser/class_parser.go:300 +0x65
github.com/jfeliu007/goplantuml/parser.(*ClassParser).processSpec(0xc0000b80f0, {0x60cee8?, 0xc0002b60c0?})
        /home/work/golang/pkg/mod/github.com/jfeliu007/[email protected]/parser/class_parser.go:340 +0x9b
github.com/jfeliu007/goplantuml/parser.(*ClassParser).handleGenDecl(...)
        /home/work/golang/pkg/mod/github.com/jfeliu007/[email protected]/parser/class_parser.go:326
github.com/jfeliu007/goplantuml/parser.(*ClassParser).parseFileDeclarations(0x589f20?, {0x60ca98?, 0xc0002b6340?})
        /home/work/golang/pkg/mod/github.com/jfeliu007/[email protected]/parser/class_parser.go:262 +0x8d
github.com/jfeliu007/goplantuml/parser.(*ClassParser).parsePackage(0xc0000b80f0, {0x60c038?, 0xc0001fad20})
        /home/work/golang/pkg/mod/github.com/jfeliu007/[email protected]/parser/class_parser.go:232 +0x398
github.com/jfeliu007/goplantuml/parser.(*ClassParser).parseDirectory(0x0?, {0xc0001ea180, 0x38})
        /home/work/golang/pkg/mod/github.com/jfeliu007/[email protected]/parser/class_parser.go:253 +0xd8
github.com/jfeliu007/goplantuml/parser.NewClassDiagramWithOptions.func1({0xc0001ea180, 0x38}, {0x60d5f0, 0xc0001f04e0}, {0x0?, 0x0?})
        /home/work/golang/pkg/mod/github.com/jfeliu007/[email protected]/parser/class_parser.go:168 +0x10d
github.com/spf13/afero.walk({0x60e200, 0x751f90}, {0xc0001ea180, 0x38}, {0x60d5f0, 0xc0001f04e0}, 0xc000173ab0)
        /home/work/golang/pkg/mod/github.com/spf13/[email protected]/path.go:44 +0x78
github.com/spf13/afero.walk({0x60e200, 0x751f90}, {0xc0000cac90, 0x30}, {0x60d5f0, 0xc00017a410}, 0xc000173ab0)
        /home/work/golang/pkg/mod/github.com/spf13/[email protected]/path.go:69 +0x32d
github.com/spf13/afero.walk({0x60e200, 0x751f90}, {0xc0000ca120, 0x2c}, {0x60d5f0, 0xc0000ad1e0}, 0xc000173ab0)
        /home/work/golang/pkg/mod/github.com/spf13/[email protected]/path.go:69 +0x32d
github.com/spf13/afero.Walk({0x60e200, 0x751f90}, {0xc0000ca120, 0x2c}, 0xc0000c5ab0)
        /home/work/golang/pkg/mod/github.com/spf13/[email protected]/path.go:105 +0x88
github.com/jfeliu007/goplantuml/parser.NewClassDiagramWithOptions(0xc000173c60)
        /home/work/golang/pkg/mod/github.com/jfeliu007/[email protected]/parser/class_parser.go:157 +0x2d2
github.com/jfeliu007/goplantuml/parser.NewClassDiagram({0xc0000a0dc0?, 0xc0000c5e70?, 0x8?}, {0x751f90?, 0x0?, 0x1f?}, 0x47?)
        /home/work/golang/pkg/mod/github.com/jfeliu007/[email protected]/parser/class_parser.go:208 +0xa5
main.main()
        /home/work/golang/pkg/mod/github.com/jfeliu007/[email protected]/cmd/goplantuml/main.go:102 +0xdb0

Other info:

$ go version
go version go1.20.6 linux/amd64

Running on Ubuntu 20.04

@githoober
Copy link

githoober commented Jul 26, 2024

I have encountered the same problem trying to generate diagrams for quite a big golang project.

image

go version go1.22.0 linux/amd64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants