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 · 2 comments
Open

panic: runtime error: index out of range #161

j1elo opened this issue Oct 9, 2023 · 2 comments

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

@jfkfrb
Copy link

jfkfrb commented Oct 2, 2024

same... go1.22.3

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

3 participants