blxzfb307 / swag-test

0 stars 0 forks source link

error message #1

Open easonlin404 opened 5 years ago

easonlin404 commented 5 years ago

I got error message like below, it's same as u? @blxzfb307

➜  ~ git clone git@github.com:blxzfb307/swag-test.git
Cloning into 'swag-test'...
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 9 (delta 0), reused 9 (delta 0), pack-reused 0
Receiving objects: 100% (9/9), done.
➜  ~ cd swag-test 
➜  swag-test git:(master) swag init -g app/main/mian.go
2019/07/06 18:10:09 Generate swagger docs....
2019/07/06 18:10:09 Generate general API Info, search dir:./, mainAPIFile:app/main/mian.go
app/main
2019/07/06 18:13:10 execute go list command, exit status 1, stdout:, stderr:go: finding github.com/labstack/echo/v4 v4.1.6
go: finding github.com/labstack/gommon v0.2.9
go: finding golang.org/x/sys v0.0.0-20190609082536-301114b31cce
go: finding golang.org/x/tools v0.0.0-20190608022120-eacb66d2a7c3
go: finding golang.org/x/net v0.0.0-20190607181551-461777fb6f67
go: finding golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5
go: finding golang.org/x/sys v0.0.0-20190602015325-4c4f7f33c9ed
go: finding github.com/mattn/go-colorable v0.1.2
can't load package: package swag-test/a: unknown import path "swag-test/a": cannot find package
blxzfb307 commented 5 years ago

May be not exactly the same. I got this error message in windows 10. @easonlin404

swag init -g app/main/mian.go
2019/07/06 18:23:38 Generate swagger docs....
2019/07/06 18:23:39 Generate general API Info, search dir:./
2019/07/06 18:23:39 execute go list command, exit status 1, stdout:, stderr:can't load package: package swag-test: unknown import path "swag-test": cannot find module providing package swag-test
easonlin404 commented 5 years ago

Ok, I will dig this issue later, thanks for your report.

blxzfb307 commented 5 years ago

@easonlin404 Thank you for your help. By the way, there is another problem in nested struct when generating the document. If I have a struct below, if will generate a strange string.

//@Success 200 {object} Foo
type Foo struct {
    Field1 []struct{
        Field2 uint
        Field3 string
    }
}

The document will like this

Foo {
    Field1 [&{%!s(token.Pos=1046) %!s(*ast.FieldList=&{1053 [0xc00036a080 0xc00036a0c0 0xc00036a100 0xc00036a140 0xc00036a180 0xc00036a200 0xc00036a240 0xc00036a280 0xc00036a2c0 0xc00036a300 0xc00036a340 0xc00036a3c0 0xc00036a480] 1695}) %!s(bool=false)}]
}

I also want to know if any method to use the anonymous structures to generating document. For example, I just use this struct once in the router handler function like below and I don't want to name them.

response := struct {
    Code int `json:"code"`
    Data []struct{
        Field1 uint `json:"field1"`
        Field2 string `json:"field2"`
    }
}{}
return c.JSON(200, response)
easonlin404 commented 5 years ago

@blxzfb307 this issue have been fixed by https://github.com/swaggo/swag/commit/91ec3e69be3fcd78e18b7f4d19f9a1785f36919d. Please go get -u github.com/swaggo/swag/cmd/swag to get v1.6.1 should be work.

easonlin404 commented 5 years ago

For anonymous structures issue, it's kind of difficult to fix it, but would be do my best to support all of cases for anonymous structures, and you can raise the issue at https://github.com/swaggo/swag/issues, I would be fix for it.

blxzfb307 commented 5 years ago

@easonlin404 sorry for bothering you again, the problem still exists in v1.6.1. Here is the screenshot. 4W(NQACVRLJVIR`G(_39_GY

easonlin404 commented 5 years ago

Should shown swag-test/app/main via go list cmd , I’m not sure that if related with windows platform, but I can fix enable with go list when —parsingDependency flag on.

blxzfb307 commented 5 years ago

Here is the screenshot of go list. It has a same error message if I use the relative path. }9$)`Y(2TR6NP%IBM4)D97I

easonlin404 commented 5 years ago

Thanks for your informations, I would disable go list if not specify flag —parsingDependency=on.

easonlin404 commented 5 years ago

@blxzfb307 please use the latest v1.6.2 to try again, thx.

blxzfb307 commented 5 years ago

It works now, thanks!