swag icon indicating copy to clipboard operation
swag copied to clipboard

Print warning message when use 1.8.11 swag to generate swagger document

Open ningyougang opened this issue 1 year ago • 10 comments

Describe the bug(not sure it is a bug)

When use latest swag(v1.8.11) to generate swagger doc, has below warning message, But a good news is, finally, the swagger document is generated successfully.

To Reproduce Steps to reproduce the behavior:

  • Download latest swag: https://github.com/swaggo/swag/releases/tag/v1.8.11 to /root/swag
  • execute /root/swag init --parseDependency --parseInternal --parseDepth 1 -g ./main.go, report below warning message
# /root/swag init --parseDependency --parseInternal --parseDepth 1 -g ./main.go
2023/03/28 11:24:34 Generate swagger docs....
2023/03/28 11:24:34 Generate general API Info, search dir:./
2023/03/28 11:24:45 warning: failed to evaluate const t1 at /home/go/src/unicode/utf8/utf8.go:29:2, strconv.ParseUint: parsing "b00000000": invalid syntax
2023/03/28 11:24:45 warning: failed to evaluate const tx at /home/go/src/unicode/utf8/utf8.go:30:2, strconv.ParseUint: parsing "b10000000": invalid syntax
2023/03/28 11:24:45 warning: failed to evaluate const t2 at /home/go/src/unicode/utf8/utf8.go:31:2, strconv.ParseUint: parsing "b11000000": invalid syntax
2023/03/28 11:24:45 warning: failed to evaluate const t3 at /home/go/src/unicode/utf8/utf8.go:32:2, strconv.ParseUint: parsing "b11100000": invalid syntax
2023/03/28 11:24:45 warning: failed to evaluate const t4 at /home/go/src/unicode/utf8/utf8.go:33:2, strconv.ParseUint: parsing "b11110000": invalid syntax
2023/03/28 11:24:45 warning: failed to evaluate const t5 at /home/go/src/unicode/utf8/utf8.go:34:2, strconv.ParseUint: parsing "b11111000": invalid syntax
2023/03/28 11:24:45 warning: failed to evaluate const maskx at /home/go/src/unicode/utf8/utf8.go:36:2, strconv.ParseUint: parsing "b00111111": invalid syntax
2023/03/28 11:24:45 warning: failed to evaluate const mask2 at /home/go/src/unicode/utf8/utf8.go:37:2, strconv.ParseUint: parsing "b00011111": invalid syntax
2023/03/28 11:24:45 warning: failed to evaluate const mask3 at /home/go/src/unicode/utf8/utf8.go:38:2, strconv.ParseUint: parsing "b00001111": invalid syntax
2023/03/28 11:24:45 warning: failed to evaluate const mask4 at /home/go/src/unicode/utf8/utf8.go:39:2, strconv.ParseUint: parsing "b00000111": invalid syntax
2023/03/28 11:24:45 warning: failed to evaluate const locb at /home/go/src/unicode/utf8/utf8.go:46:2, strconv.ParseUint: parsing "b10000000": invalid syntax
2023/03/28 11:24:45 warning: failed to evaluate const hicb at /home/go/src/unicode/utf8/utf8.go:47:2, strconv.ParseUint: parsing "b10111111": invalid syntax
2023/03/28 11:24:45 warning: failed to evaluate const mProfCycleWrap at /home/go/src/runtime/mprof.go:159:7, reflect: call of reflect.Value.Len on zero Value
...
2023/03/28 11:24:45 create docs.go at docs/docs.go
2023/03/28 11:24:45 create swagger.json at docs/swagger.json
2023/03/28 11:24:45 create swagger.yaml at docs/swagger.yaml

I tried several machines, still exist the problem.

Expected behavior

  • No any warning message (Has warning message)
  • Swagger doc is created successfully (This is ok)

Screenshots If applicable, add screenshots to help explain your problem.

Your swag version e.g. 1.8.11

Your go version e.g. 1.17.13

Desktop (this issue has no relation with the Desktop infomation):

  • OS: Windows
  • Browser: chrome
  • Version: 111.0.5563.65

ningyougang avatar Mar 28 '23 03:03 ningyougang

on mac computer , and not generate right doc

huqiuyun avatar May 17 '23 09:05 huqiuyun

Linux tester 5.15.0-69-generic #76~20.04.1-Ubuntu got same problem on v1.8.12

panhow avatar May 23 '23 09:05 panhow

I got this too:

2023/06/07 11:12:36 warning: failed to get package name in dir: ./, error: execute go list command, exit status 1, stdout:, stderr:no Go files in /home/jianjianxu/work/projects/fzpm2022_api_go
2023/06/07 11:12:38 warning: failed to evaluate const locb at /home/ko/go/pkg/mod/github.com/pelletier/go-toml/[email protected]/internal/characters/utf8.go:183:2, strconv.ParseUint: parsing "b10000000": invalid syntax
2023/06/07 11:12:38 warning: failed to evaluate const hicb at /home/ko/go/pkg/mod/github.com/pelletier/go-toml/[email protected]/internal/characters/utf8.go:184:2, strconv.ParseUint: parsing "b10111111": invalid syntax

jianjianxu avatar Jun 07 '23 03:06 jianjianxu

After upgrade the swag version to

# swag --version
swag version v1.8.12

Can create the swagger doc succesfully, but still exist below warning log

2023/03/28 11:24:45 warning: failed to evaluate const t5 at /home/go/src/unicode/utf8/utf8.go:34:2, strconv.ParseUint: parsing "b11111000": invalid syntax

Now, we ignored above invalid syntax warning log :(

ningyougang avatar Aug 07 '23 07:08 ningyougang

This got fixed in v1.16.3 with go1.20

sundowndev avatar Feb 20 '24 14:02 sundowndev

This got fixed in v1.16.3 with go1.20

How?! I'm running the latest version:

$ swag --version
swag version v1.16.3

And I still see this warning in my buidls:

$ swag init -d ./cmd/backend,./internal,./types --parseInternal --parseDependency
2024/03/09 15:36:28 Generate swagger docs....
2024/03/09 15:36:28 Generate general API Info, search dir:./cmd/backend
2024/03/09 15:36:28 Generate general API Info, search dir:./internal
2024/03/09 15:36:28 Generate general API Info, search dir:./types
2024/03/09 15:36:28 warning: failed to evaluate const mProfCycleWrap at /opt/homebrew/Cellar/go/1.22.1/libexec/src/runtime/mprof.go:168:7, reflect: call of reflect.Value.Len on zero Value
...

prologic avatar Mar 09 '24 05:03 prologic

@prologic The upgrade fixed it for me on go1.20, you're using go1.22 so I don't know. May be it was specific to my project.

sundowndev avatar Mar 09 '24 08:03 sundowndev

This got fixed in v1.16.3 with go1.20

@sundowndev I'm running the specified version:

$ go version 
go version go1.20.2
$ swag --version
swag version v1.16.3

And the problem still exists:

$ swag init --parseDependency --parseInternal
2024/05/11 18:58:01 Generate swagger docs....
2024/05/11 18:58:01 Generate general API Info, search dir:./
2024/05/11 18:58:02 warning: failed to evaluate const mProfCycleWrap at /usr/local/go/src/runtime/mprof.go:165:7, reflect: call of reflect.Value.Len on zero Value
...

only1970 avatar May 11 '24 11:05 only1970

@prologic The upgrade fixed it for me on go1.20, you're using go1.22 so I don't know. May be it was specific to my project.

i'm also use the specified version:

go version
go version go1.20.14 darwin/arm64
swag --version
swag version v1.16.3

but the problem still exists:

cd cmd && swag init -g main.go --parseDependency --parseInternal
2024/06/25 17:06:46 Generate swagger docs....
2024/06/25 17:06:46 Generate general API Info, search dir:./
2024/06/25 17:06:51 warning: failed to evaluate const mProfCycleWrap at /opt/homebrew/Cellar/[email protected]/1.20.14/libexec/src/runtime/mprof.go:165:7, reflect: call of reflect.Value.Len on zero Value
2024/06/25 17:06:51 create docs.go at docs/docs.go
2024/06/25 17:06:51 create swagger.json at docs/swagger.json
2024/06/25 17:06:51 create swagger.yaml at docs/swagger.yaml

there are some hardware info here :

 system_profiler SPHardwareDataType
Hardware:

    Hardware Overview:

      Model Name: MacBook Pro
      Model Identifier: Mac14,10
      Model Number: Z17400063CH/A
      Chip: Apple M2 Pro
      Total Number of Cores: 12 (8 performance and 4 efficiency)
      Memory: 32 GB
      System Firmware Version: 8422.141.2
      OS Loader Version: 8422.141.2

Can we do something to fix it?

ayuRain avatar Jun 25 '24 09:06 ayuRain