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

invalid memory address or nil pointer dereference #1911

Open
wanjianwei opened this issue Oct 23, 2024 · 3 comments
Open

invalid memory address or nil pointer dereference #1911

wanjianwei opened this issue Oct 23, 2024 · 3 comments

Comments

@wanjianwei
Copy link

Describe the bug
Got error: "panic: runtime error: invalid memory address or nil pointer dereference" when i execute the script:
"swag init -d ./ -g router.go", the error trace is as follow:

goroutine 1 [running]:
github.com/swaggo/swag.getFuncDoc({0x100951dc0?, 0x140007a3c70?})
/Users/jway/Desktop/Dev/swag/parser.go:1062 +0x88
github.com/swaggo/swag.getFuncDoc({0x100951fc0?, 0x140007a9f00?})
/Users/jway/Desktop/Dev/swag/parser.go:1055 +0x138
github.com/swaggo/swag.(*Parser).ParseRouterAPIInfo(0x14000000ea0, 0x140007cef40)
/Users/jway/Desktop/Dev/swag/parser.go:1088 +0xbc
github.com/swaggo/swag.(*PackagesDefinitions).RangeFiles(0x140001b9350, 0x14001ceb488)
/Users/jway/Desktop/Dev/swag/packages.go:107 +0x2cc
github.com/swaggo/swag.(*Parser).ParseAPIMultiSearchDir(0x14000000ea0, {0x140001f63e0, 0x1, 0x0?}, {0x16fa7f753, 0xd}, 0x64)
/Users/jway/Desktop/Dev/swag/parser.go:457 +0x4a4
github.com/swaggo/swag/gen.(*Gen).Build(0x140001b9170, 0x140001f8000)
/Users/jway/Desktop/Dev/swag/gen/gen.go:221 +0x6a8
main.initAction(0x14000160420?)
/Users/jway/Desktop/Dev/swag/cmd/swag/main.go:243 +0x914
github.com/urfave/cli/v2.(*Command).Run(0x14000160420, 0x14000039d00, {0x140001cc370, 0x5, 0x5})
/Users/jway/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:276 +0x754
github.com/urfave/cli/v2.(*Command).Run(0x14000160840, 0x14000039bc0, {0x140000201e0, 0x6, 0x6})
/Users/jway/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:269 +0x964
github.com/urfave/cli/v2.(*App).RunContext(0x140001a6400, {0x1009cf058?, 0x100d50c80}, {0x140000201e0, 0x6, 0x6})
/Users/jway/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:333 +0x53c
github.com/urfave/cli/v2.(*App).Run(...)
/Users/jway/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:307
main.main()
/Users/jway/Desktop/Dev/swag/cmd/swag/main.go:333 +0x614
make: *** [swagger] Error 2

Your swag version
e.g. 1.16.4

Your go version
e.g. 1.21.12

Desktop (please complete the following information):

  • OS: macos 12.4
@ubogdan
Copy link
Contributor

ubogdan commented Oct 24, 2024

As you may see in the release log, there are many PRs. It's a big surprise for me.
Can you please provide an annotation that generates this?

@YanShulinjj
Copy link

This panic is got when the req struct contains interface{} type, eg.type Req struct { data interface{} }

@ubogdan
Copy link
Contributor

ubogdan commented Nov 11, 2024

This is an OSS project. Any contribution is welcome.

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