swaggo / swag

Automatically generate RESTful API documentation with Swagger 2.0 for Go.
MIT License
10.63k stars 1.19k forks source link

cannot find all dependencies, <nil> #1232

Open rowdyroad opened 2 years ago

rowdyroad commented 2 years ago

Describe the bug swag init --parseDependency --parseInternal --parseDepth 5 --output docs/client -g cmd/client/main.go --exclude=internal/apps/crm,internal/apps/api 2022/06/16 14:15:28 Generate general API Info, search dir:./ 2022/06/16 14:15:28 Generate swagger docs.... 2022/06/16 14:15:28 warning: failed to get package name in dir: ./, error: execute go list command, exit status 1, stdout:, stderr:no Go files in /app 2022/06/16 14:15:40 pkg /app/cmd/client cannot find all dependencies,

To Reproduce swag init --parseDependency --parseInternal --parseDepth 5 --output docs/client -g cmd/client/main.go --exclude=internal/apps/crm,internal/apps/api

Expected behavior swagger docs

Your swag version 1.8.3

Your go version 1.18

Desktop (please complete the following information): Ubuntu 22.04

Additional context Downgrade to 1.8.2 solve the problem

ubogdan commented 2 years ago

I have no clue what the issue is. We need a way to reproduce the error in order to fix it.

smallfish06 commented 2 years ago

@ubogdan @pytimer I also have same issue with @rowdyroad

we need to update README.md since there's no description for this option

First of all we need to describe exact error, now it's hard to see what's error pkg .... cannot find all dependencies, <nil> https://github.com/swaggo/swag/blob/97ea98ec1bd528b87a0fd6f5e3493a052dc762c0/parser.go#L297-L300

return fmt.Errorf("pkg %s cannot find all dependencies, %s", pkgName, err)

should be

return fmt.Errorf("pkg %s cannot find all dependencies, %s", pkgName, err.Error())

For me I'm using echo and for the -g option cmd/.../main.go If I execute go list ./ it says no Go files in /Users/,,,/,,,/,,, to generate go list properly I need to execute go list ./.... and for in docker (WORKDIR /app), it says `no Go files in /app' as expected.

I didn't look into https://github.com/swaggo/swag/pull/1108 well, but.. seems direct call of go list without some parameter may cause this problem

https://github.com/swaggo/swag/blob/0e2ec6ccb687ad91e20d33f4e433c460ca41acaa/golist.go#L13-L16

pytimer commented 2 years ago

You can try setting swag init --parseGoList=false.

Can you support some code to reproduce the error?

nikk-gr commented 1 year ago

Error is an interface. It consists of two pointers: type pointer and data pointer

It's equal to nil if only both pointers is nil

fmt.Errorf returns <nil> so data pointer is nil err != nil -> type pointer is not nil

smhmh commented 4 months ago

I have same issue. It's just a network problem!! I get 403 forbidden error on resolving https://proxy.golang.org/github.com/gabriel-vasile/mimetype/@v/v1.4.3.zip

KimJoongyeop commented 4 weeks ago

You can try setting swag init --parseGoList=false.

Can you support some code to reproduce the error?

I'm using echo. --parseGoList=false It took some time, but it worked!

swag init -g cmd/{projectName}/main.go --pd --parseGoList=false --parseDepth=1