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

swag init stop parsing #1916

Open
rcodina-tp opened this issue Oct 24, 2024 · 2 comments
Open

swag init stop parsing #1916

rcodina-tp opened this issue Oct 24, 2024 · 2 comments

Comments

@rcodina-tp
Copy link

Describe the bug
just when I run swagg init with v.1.16.3 throw me an nil pointer error

To Reproduce
Steps to reproduce the behavior:
we have this dependencies go.mod
github.com/swaggo/files v1.0.1
github.com/swaggo/gin-swagger v1.6.0
github.com/swaggo/swag v1.16.3

Expected behavior
just create de docs folder

Screenshots
image

Your swag version
e.g. 1.16.3

Your go version
e.g. 1.22.0

Desktop (please complete the following information):

  • OS: [e.g. windows 11]
  • Browser: [e.g. chrome]
  • Version: [e.g. 22]

Additional context
swag init
2024/10/24 17:36:33 Generate swagger docs....
2024/10/24 17:36:33 Generate general API Info, search dir:./
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x18 pc=0xe288c6]

goroutine 1 [running]:
github.com/swaggo/swag.(*Parser).Skip.walkWith.func1({0xc000493080, 0x36}, {0x0, 0x0})
C:/Users/rcodina/go/pkg/mod/github.com/swaggo/[email protected]/parser.go:1888 +0x26
github.com/swaggo/swag.(*Parser).Skip(0x102b220?, {0xc000493080?, 0xc0000b4cf0?}, {0x0?, 0x0?})
C:/Users/rcodina/go/pkg/mod/github.com/swaggo/[email protected]/parser.go:1883 +0x6f
github.com/swaggo/swag.(*Parser).getAllGoFileInfo.func1({0xc000493080, 0x36}, {0x0, 0x0}, {0xc000151280?, 0xe27d1f?})
C:/Users/rcodina/go/pkg/mod/github.com/swaggo/[email protected]/parser.go:1778 +0x7b
path/filepath.walk({0xc0000b6080, 0x2a}, {0x1030b70, 0xc0001201c0}, 0xc000151630)
C:/Program Files/Go/src/path/filepath/path.go:497 +0x1d4
path/filepath.walk({0xc000020930, 0x20}, {0x1030b70, 0xc000301f80}, 0xc000151630)
C:/Program Files/Go/src/path/filepath/path.go:501 +0x257
path/filepath.walk({0xc00008c528, 0x17}, {0x1030b70, 0xc000301f10}, 0xc000151630)
C:/Program Files/Go/src/path/filepath/path.go:501 +0x257
path/filepath.walk({0xc00000bc1d, 0x3}, {0x1030b70, 0xc000301ea0}, 0xc000151630)
C:/Program Files/Go/src/path/filepath/path.go:501 +0x257
path/filepath.walk({0xf4d8ef, 0x2}, {0x1030b70, 0xc000189960}, 0xc000151630)
C:/Program Files/Go/src/path/filepath/path.go:501 +0x257
path/filepath.Walk({0xf4d8ef, 0x2}, 0xc000151630)
C:/Program Files/Go/src/path/filepath/path.go:572 +0x66
github.com/swaggo/swag.(*Parser).getAllGoFileInfo(0xf4d8ef?, {0xc0001993b0?, 0x1026d70?}, {0xf4d8ef?, 0x0?})
C:/Users/rcodina/go/pkg/mod/github.com/swaggo/[email protected]/parser.go:1777 +0xb5
github.com/swaggo/swag.(*Parser).ParseAPIMultiSearchDir(0xc000126ea0, {0xc00017f4e0, 0x1, 0x0?}, {0xf50472, 0x7}, 0x64)
C:/Users/rcodina/go/pkg/mod/github.com/swaggo/[email protected]/parser.go:398 +0x294
github.com/swaggo/swag/gen.(*Gen).Build(0xc000179500, 0xc000002180)
C:/Users/rcodina/go/pkg/mod/github.com/swaggo/[email protected]/gen/gen.go:221 +0x8fa
main.initAction(0xc00017c700?)
C:/Users/rcodina/go/pkg/mod/github.com/swaggo/[email protected]/cmd/swag/main.go:243 +0xada
github.com/urfave/cli/v2.(*Command).Run(0xc000126a20, 0xc000065d40)
C:/Users/rcodina/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:163 +0x583
github.com/urfave/cli/v2.(*App).RunContext(0xc0000781a0, {0x102fd98?, 0x13eb4e0}, {0xc00003e3e0, 0x2, 0x2})
C:/Users/rcodina/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:313 +0xaa5
github.com/urfave/cli/v2.(*App).Run(...)
C:/Users/rcodina/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:224
main.main()
C:/Users/rcodina/go/pkg/mod/github.com/swaggo/[email protected]/cmd/swag/main.go:333 +0x615

@ZiRunHua
Copy link

According to your log, you are using 1.16.4, but this problem may be in many versions, I also encountered it, and it has been bothering me for a long time.
Check the error log found because the file does not have read permission, the problem may come from the https://github.com/swaggo/swag/blob/v1.16.4/parser.go#L1777, I doubt there is no check os.FileInfo and error.

@ZiRunHua
Copy link

If allowed, I would like to submit a 'pull request' to have it display the correct error content

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