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

cannot find all dependencies, <nil> #1232

Open
rowdyroad opened this issue Jun 16, 2022 · 4 comments
Open

cannot find all dependencies, <nil> #1232

rowdyroad opened this issue Jun 16, 2022 · 4 comments

Comments

@rowdyroad
Copy link

rowdyroad commented Jun 16, 2022

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
Copy link
Contributor

ubogdan commented Jun 18, 2022

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

@smallfish06
Copy link

smallfish06 commented Jun 19, 2022

@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>

swag/parser.go

Lines 297 to 300 in 97ea98e

if err != nil {
return fmt.Errorf("pkg %s cannot find all dependencies, %s", pkgName, err)
}

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 #1108 well, but.. seems direct call of go list without some parameter may cause this problem

swag/golist.go

Lines 13 to 16 in 0e2ec6c

func listPackages(ctx context.Context, dir string, env []string, args ...string) (pkgs []*build.Package, finalErr error) {
cmd := exec.CommandContext(ctx, "go", append([]string{"list", "-json", "-e"}, args...)...)
cmd.Env = env
cmd.Dir = dir

@pytimer
Copy link
Contributor

pytimer commented Jun 20, 2022

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

Can you support some code to reproduce the error?

@nikk-gr
Copy link

nikk-gr commented Aug 28, 2023

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

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

5 participants