Closed nicolasassi closed 1 year ago
If I change the models for the following:
type Type string
const (
TypePerson Type = "person" // person
TypeBusiness Type = "business" /* business */
)
type customerIn struct {
ClientId string `json:"client_id"`
Type Type `json:"type"`
}
type customerOut struct {
Id string `json:"id"`
ClientId string `json:"client_id"`
Type Type `json:"type"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
With the intention of using the new enums feature the error changes for the following:
swag init -g service/server/server.go --pd
2022/11/22 08:16:29 Generate swagger docs....
2022/11/22 08:16:29 Generate general API Info, search dir:./
2022/11/22 08:16:29 warning: failed to get package name in dir: ./, error: execute go list command, exit status 1, stdout:, stderr:no Go files in /Users/nicolas.sassi/dev/soul/acaiah
panic: interface conversion: interface {} is string, not int
goroutine 1 [running]:
github.com/swaggo/swag.(*PackageDefinitions).evaluateConstValue(0xc001020000, 0x1a63878?, 0x90?, {0x165bee0?, 0xc001536a20?}, {0x165a460, 0xc000089820}, 0x1066467?)
/Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/package.go:132 +0x113f
github.com/swaggo/swag.(*PackageDefinitions).evaluateConstValue(0xc001020000, 0xc0090a8510?, 0xc006ba3e00?, {0x165bee0?, 0xc001536c60?}, {0x165a460, 0xc000089820}, 0xc0001d1aa0?)
/Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/package.go:115 +0xd9
github.com/swaggo/swag.(*PackagesDefinitions).EvaluateConstValue(0xc005711698?, 0xc001020000, 0xc0058b8bc0, 0x0)
/Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/packages.go:282 +0x19d
github.com/swaggo/swag.(*PackagesDefinitions).evaluateAllConstVariables(...)
/Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/packages.go:265
github.com/swaggo/swag.(*PackagesDefinitions).ParseTypes(0xc000089820)
/Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/packages.go:110 +0x254
github.com/swaggo/swag.(*Parser).ParseAPIMultiSearchDir(0xc000200000, {0xc0001fc0f0?, 0x1?, 0x0?}, {0x7ff7bfeff555?, 0x18?}, 0x64)
/Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/parser.go:375 +0x3bf
github.com/swaggo/swag/gen.(*Gen).Build(0xc0001d1950, 0xc0001d82a0)
/Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/gen/gen.go:182 +0x637
main.initAction(0xc0001eaa00?)
/Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/cmd/swag/main.go:158 +0x7bd
github.com/urfave/cli/v2.(*Command).Run(0xc0001a6a20, 0xc0001e8300)
/Users/nicolas.sassi/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/command.go:163 +0x5dc
github.com/urfave/cli/v2.(*App).RunContext(0xc0000bd380, {0x165cef0?, 0xc00002c108}, {0xc0000240a0, 0x5, 0x5})
/Users/nicolas.sassi/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:313 +0xb7d
github.com/urfave/cli/v2.(*App).Run(...)
/Users/nicolas.sassi/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:224
main.main()
/Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/cmd/swag/main.go:229 +0x5c5
make: *** [swagger] Error 2
It seems odd. As the exception reports, there must be some const expressions like 1<<-1, and "aaa"-"bbb", could you please find out what are they?
It seems odd. As the exception reports, there must be some const expressions like 1<<-1, and "aaa"-"bbb", could you please find out what are they?
The only consts declared are the ones in the models mentioned. There are no other const in the project that could affect the definition... Is it possible that the current implementation is falling because it tries to parse all consts in packages imported as well?
It seems odd. As the exception reports, there must be some const expressions like 1<<-1, and "aaa"-"bbb", could you please find out what are they?
The only consts declared are the ones in the models mentioned. There are no other const in the project that could affect the definition... Is it possible that the current implementation is falling because it tries to parse all consts in packages imported as well?
Yes, it will first parse and evaluate all the consts, including dependency if --pd set, because the type of a const may be implicit and need to be evaluate out.
It seems odd. As the exception reports, there must be some const expressions like 1<<-1, and "aaa"-"bbb", could you please find out what are they?
The only consts declared are the ones in the models mentioned. There are no other const in the project that could affect the definition... Is it possible that the current implementation is falling because it tries to parse all consts in packages imported as well?
Yes, it will first parse and evaluate all the consts, including dependency if --pd set, because the type of a const may be implicit and need to be evaluate out.
Got it! This project is quite simple so the consts are only strings, there are no expressions... My question would be if the implementation might be also trying to evaluate third-party packages imported by the application. In this case there might be more consts with expressions but I wouldn't know.
I'll add some exception detecting code to output where it is
Could you please try this new branch to find out the suspect expression as soon as possible?
I cloned the repo and checkout to the origin/parse-error-position
branch. Then in the root of the repo I ran go install .
.
Running
swag init -g service/server/server.go --pd
swag fmt -g service/server/server.go
In the service the output didn't change yet. Am I missing something?
there are some warning failed to parse const...
in the std output
there are some warning
failed to parse const...
in the std output
The std output seems pretty much the same
swag init -g service/server/server.go --requiredByDefault --pd
2022/11/22 14:05:53 Generate swagger docs....
2022/11/22 14:05:53 Generate general API Info, search dir:./
2022/11/22 14:05:53 warning: failed to get package name in dir: ./, error: execute go list command, exit status 1, stdout:, stderr:no Go files in /Users/nicolas.sassi/dev/soul/acaiah
panic: interface conversion: interface {} is string, not int
goroutine 1 [running]:
github.com/swaggo/swag.(*PackageDefinitions).evaluateConstValue(0xc000ce3f40, 0x1a65498?, 0x90?, {0x165bee0?, 0xc0014da9c0?}, {0x165a460, 0xc0001b1800}, 0xc00f941588?)
/Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/package.go:132 +0x113f
github.com/swaggo/swag.(*PackageDefinitions).evaluateConstValue(0xc000ce3f40, 0xc01d29f260?, 0xc0068b7b30?, {0x165bee0?, 0xc0014da9f0?}, {0x165a460, 0xc0001b1800}, 0xc000249a70?)
/Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/package.go:115 +0xd9
github.com/swaggo/swag.(*PackagesDefinitions).EvaluateConstValue(0xc00f941698?, 0xc000ce3f40, 0xc00580e740, 0x0)
/Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/packages.go:282 +0x19d
github.com/swaggo/swag.(*PackagesDefinitions).evaluateAllConstVariables(...)
/Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/packages.go:265
github.com/swaggo/swag.(*PackagesDefinitions).ParseTypes(0xc0001b1800)
/Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/packages.go:110 +0x254
github.com/swaggo/swag.(*Parser).ParseAPIMultiSearchDir(0xc00027a000, {0xc0002760d0?, 0x1?, 0x0?}, {0x7ff7bfeff53d?, 0x18?}, 0x64)
/Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/parser.go:375 +0x3bf
github.com/swaggo/swag/gen.(*Gen).Build(0xc000249920, 0xc0002502a0)
/Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/gen/gen.go:182 +0x637
main.initAction(0xc000266780?)
/Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/cmd/swag/main.go:158 +0x7bd
github.com/urfave/cli/v2.(*Command).Run(0xc000220ea0, 0xc000262300)
/Users/nicolas.sassi/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/command.go:163 +0x5dc
github.com/urfave/cli/v2.(*App).RunContext(0xc000195a00, {0x165cef0?, 0xc000196008}, {0xc000192120, 0x6, 0x6})
/Users/nicolas.sassi/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:313 +0xb7d
github.com/urfave/cli/v2.(*App).Run(...)
/Users/nicolas.sassi/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:224
main.main()
/Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/cmd/swag/main.go:229 +0x5c5
make: *** [swagger] Error 2
Your re-compiling have not succeeded, I think, it is not the newest version
The warning is supposed to be
warning: failed to evaluate const xxx at xxxxx\xxx.go:18:2, interface conversion: interface {} is string, not int
I got same problems, too. But if I changed swaggo version to 1.8.7, everything is fine.
Your swag version go install github.com/swaggo/swag/cmd/swag@v.1.8.8
Your go version 1.19.2 darwin/arm64
Desktop (please complete the following information):
OS: macOS Monterey 12.6
I got same problems, too. But if I changed swaggo version to 1.8.7, everything is fine.
Your swag version go install github.com/swaggo/swag/cmd/swag@v.1.8.8
Your go version 1.19.2 darwin/arm64
Desktop (please complete the following information):
OS: macOS Monterey 12.6
Thank you for feedback, however I want to know what expressions made this panic. Can you please try the master branch swag to find out it?
====compile output==== panic: runtime error: negative shift amount
goroutine 1 [running]: github.com/swaggo/swag.(PackageDefinitions).evaluateConstValue(0x14000fc55e0, 0x140105e72c0?, 0x140105e81c8?, {0x1045f1298?, 0x14001646d80?}, {0x1045ef8c0, 0x14000075820}, 0x14003d8c428?) /Users/faustfu/go/pkg/mod/github.com/swaggo/swag@v1.8.8/package.go:146 +0xdcc github.com/swaggo/swag.(PackagesDefinitions).EvaluateConstValue(0x1400e4bf668?, 0x14000fc55e0, 0x140101ce300, 0x0) /Users/faustfu/go/pkg/mod/github.com/swaggo/swag@v1.8.8/packages.go:282 +0x144 github.com/swaggo/swag.(PackagesDefinitions).evaluateAllConstVariables(...) /Users/faustfu/go/pkg/mod/github.com/swaggo/swag@v1.8.8/packages.go:265 github.com/swaggo/swag.(PackagesDefinitions).ParseTypes(0x14000075820) /Users/faustfu/go/pkg/mod/github.com/swaggo/swag@v1.8.8/packages.go:110 +0x1d0 github.com/swaggo/swag.(Parser).ParseAPIMultiSearchDir(0x140001e8000, {0x140001e2100?, 0x1?, 0x0?}, {0x10443af8a?, 0x7?}, 0x64) /Users/faustfu/go/pkg/mod/github.com/swaggo/swag@v1.8.8/parser.go:375 +0x29c github.com/swaggo/swag/gen.(Gen).Build(0x140001af920, 0x140001a82a0) /Users/faustfu/go/pkg/mod/github.com/swaggo/swag@v1.8.8/gen/gen.go:182 +0x4dc main.initAction(0x140001d2780?) /Users/faustfu/go/pkg/mod/github.com/swaggo/swag@v1.8.8/cmd/swag/main.go:158 +0x698 github.com/urfave/cli/v2.(Command).Run(0x14000000c60, 0x140001d0340) /Users/faustfu/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/command.go:163 +0x4fc github.com/urfave/cli/v2.(App).RunContext(0x140000a3520, {0x1045f22b0?, 0x14000024110}, {0x140000201e0, 0x6, 0x6}) /Users/faustfu/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:313 +0x860 github.com/urfave/cli/v2.(*App).Run(...) /Users/faustfu/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:224 main.main() /Users/faustfu/go/pkg/mod/github.com/swaggo/swag@v1.8.8/cmd/swag/main.go:229 +0x65c make: *** [swag] Error 2
====compile output==== panic: runtime error: negative shift amount
goroutine 1 [running]: github.com/swaggo/swag.(PackageDefinitions).evaluateConstValue(0x14000fc55e0, 0x140105e72c0?, 0x140105e81c8?, {0x1045f1298?, 0x14001646d80?}, {0x1045ef8c0, 0x14000075820}, 0x14003d8c428?) /Users/faustfu/go/pkg/mod/github.com/swaggo/swag@v1.8.8/package.go:146 +0xdcc github.com/swaggo/swag.(PackagesDefinitions).EvaluateConstValue(0x1400e4bf668?, 0x14000fc55e0, 0x140101ce300, 0x0) /Users/faustfu/go/pkg/mod/github.com/swaggo/swag@v1.8.8/packages.go:282 +0x144 github.com/swaggo/swag.(PackagesDefinitions).evaluateAllConstVariables(...) /Users/faustfu/go/pkg/mod/github.com/swaggo/swag@v1.8.8/packages.go:265 github.com/swaggo/swag.(PackagesDefinitions).ParseTypes(0x14000075820) /Users/faustfu/go/pkg/mod/github.com/swaggo/swag@v1.8.8/packages.go:110 +0x1d0 github.com/swaggo/swag.(Parser).ParseAPIMultiSearchDir(0x140001e8000, {0x140001e2100?, 0x1?, 0x0?}, {0x10443af8a?, 0x7?}, 0x64) /Users/faustfu/go/pkg/mod/github.com/swaggo/swag@v1.8.8/parser.go:375 +0x29c github.com/swaggo/swag/gen.(Gen).Build(0x140001af920, 0x140001a82a0) /Users/faustfu/go/pkg/mod/github.com/swaggo/swag@v1.8.8/gen/gen.go:182 +0x4dc main.initAction(0x140001d2780?) /Users/faustfu/go/pkg/mod/github.com/swaggo/swag@v1.8.8/cmd/swag/main.go:158 +0x698 github.com/urfave/cli/v2.(Command).Run(0x14000000c60, 0x140001d0340) /Users/faustfu/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/command.go:163 +0x4fc github.com/urfave/cli/v2.(App).RunContext(0x140000a3520, {0x1045f22b0?, 0x14000024110}, {0x140000201e0, 0x6, 0x6}) /Users/faustfu/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:313 +0x860 github.com/urfave/cli/v2.(*App).Run(...) /Users/faustfu/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:224 main.main() /Users/faustfu/go/pkg/mod/github.com/swaggo/swag@v1.8.8/cmd/swag/main.go:229 +0x65c make: *** [swag] Error 2
This is not helpful to me, someone above have provided this log
It seems odd. As the exception reports, there must be some const expressions like 1<<-1, and "aaa"-"bbb", could you please find out what are they?
@faustfu-WaveGIS
2022/11/28 14:15:40 Generate swagger docs.... 2022/11/28 14:15:40 Generate general API Info, search dir:/Users/faustfu/wave/wg_equipment_manager/iow-upload 2022/11/28 14:15:41 warning: failed to evaluate const uintSize at /usr/local/go/src/math/bits/bits.go:11:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const uintSize at /usr/local/go/src/math/bits/bits.go:11:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const uintSize at /usr/local/go/src/math/bits/bits.go:11:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const uintSize at /usr/local/go/src/math/bits/bits.go:11:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const MaxBase at /usr/local/go/src/math/big/natconv.go:24:7, interface conversion: interface {} is string, not int 2022/11/28 14:15:41 warning: failed to evaluate const maxBaseSmall at /usr/local/go/src/math/big/natconv.go:25:7, interface conversion: interface {} is string, not int 2022/11/28 14:15:41 warning: failed to evaluate const uintSize at /usr/local/go/src/math/bits/bits.go:11:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const maxArrayLen at /Users/faustfu/go/pkg/mod/github.com/ugorji/go/codec@v1.2.7/helper_internal.go:8:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const wordSizeBits at /Users/faustfu/go/pkg/mod/github.com/ugorji/go/codec@v1.2.7/helper.go:250:2, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const wordSizeBits at /Users/faustfu/go/pkg/mod/github.com/ugorji/go/codec@v1.2.7/helper.go:250:2, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const jsonU4Chk1 at /Users/faustfu/go/pkg/mod/github.com/ugorji/go/codec@v1.2.7/json.go:65:2, interface conversion: interface {} is string, not int 2022/11/28 14:15:41 warning: failed to evaluate const jsonU4Chk0 at /Users/faustfu/go/pkg/mod/github.com/ugorji/go/codec@v1.2.7/json.go:66:2, interface conversion: interface {} is string, not int 2022/11/28 14:15:41 warning: failed to evaluate const toLower at /usr/local/go/src/net/textproto/reader.go:602:7, interface conversion: interface {} is string, not int 2022/11/28 14:15:41 warning: failed to evaluate const tooBig at /usr/local/go/src/encoding/gob/decoder.go:18:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const uintSize at /usr/local/go/src/math/bits/bits.go:11:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const uintSize at /usr/local/go/src/math/bits/bits.go:11:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const UpperLower at /usr/local/go/src/unicode/letter.go:83:2, interface conversion: interface {} is int, not string 2022/11/28 14:15:41 warning: failed to evaluate const intSize at /usr/local/go/src/math/const.go:40:2, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const intSize at /usr/local/go/src/math/const.go:40:2, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const intSize at /usr/local/go/src/math/const.go:40:2, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const intSize at /usr/local/go/src/math/const.go:40:2, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const base at /Users/faustfu/go/pkg/mod/golang.org/x/text@v0.3.7/internal/language/lookup.go:76:7, interface conversion: interface {} is string, not int 2022/11/28 14:15:41 warning: failed to evaluate const intSize at /usr/local/go/src/strconv/atoi.go:52:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const intSize at /usr/local/go/src/strconv/atoi.go:52:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const uintSize at /usr/local/go/src/strconv/decimal.go:106:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const uintSize at /usr/local/go/src/strconv/decimal.go:106:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const intBits at /usr/local/go/src/fmt/scan.go:939:2, runtime error: negative shift amount 2022/11/28 14:15:41 create docs.go at docs/docs.go 2022/11/28 14:15:41 create swagger.json at docs/swagger.json 2022/11/28 14:15:41 create swagger.yaml at docs/swagger.yaml
no, I did not use those statements in my code.
I used swaggo source to run and output is below.
2022/11/28 14:15:40 Generate swagger docs.... 2022/11/28 14:15:40 Generate general API Info, search dir:/Users/faustfu/wave/wg_equipment_manager/iow-upload 2022/11/28 14:15:41 warning: failed to evaluate const uintSize at /usr/local/go/src/math/bits/bits.go:11:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const uintSize at /usr/local/go/src/math/bits/bits.go:11:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const uintSize at /usr/local/go/src/math/bits/bits.go:11:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const uintSize at /usr/local/go/src/math/bits/bits.go:11:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const MaxBase at /usr/local/go/src/math/big/natconv.go:24:7, interface conversion: interface {} is string, not int 2022/11/28 14:15:41 warning: failed to evaluate const maxBaseSmall at /usr/local/go/src/math/big/natconv.go:25:7, interface conversion: interface {} is string, not int 2022/11/28 14:15:41 warning: failed to evaluate const uintSize at /usr/local/go/src/math/bits/bits.go:11:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const maxArrayLen at /Users/faustfu/go/pkg/mod/github.com/ugorji/go/codec@v1.2.7/helper_internal.go:8:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const wordSizeBits at /Users/faustfu/go/pkg/mod/github.com/ugorji/go/codec@v1.2.7/helper.go:250:2, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const wordSizeBits at /Users/faustfu/go/pkg/mod/github.com/ugorji/go/codec@v1.2.7/helper.go:250:2, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const jsonU4Chk1 at /Users/faustfu/go/pkg/mod/github.com/ugorji/go/codec@v1.2.7/json.go:65:2, interface conversion: interface {} is string, not int 2022/11/28 14:15:41 warning: failed to evaluate const jsonU4Chk0 at /Users/faustfu/go/pkg/mod/github.com/ugorji/go/codec@v1.2.7/json.go:66:2, interface conversion: interface {} is string, not int 2022/11/28 14:15:41 warning: failed to evaluate const toLower at /usr/local/go/src/net/textproto/reader.go:602:7, interface conversion: interface {} is string, not int 2022/11/28 14:15:41 warning: failed to evaluate const tooBig at /usr/local/go/src/encoding/gob/decoder.go:18:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const uintSize at /usr/local/go/src/math/bits/bits.go:11:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const uintSize at /usr/local/go/src/math/bits/bits.go:11:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const UpperLower at /usr/local/go/src/unicode/letter.go:83:2, interface conversion: interface {} is int, not string 2022/11/28 14:15:41 warning: failed to evaluate const intSize at /usr/local/go/src/math/const.go:40:2, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const intSize at /usr/local/go/src/math/const.go:40:2, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const intSize at /usr/local/go/src/math/const.go:40:2, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const intSize at /usr/local/go/src/math/const.go:40:2, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const base at /Users/faustfu/go/pkg/mod/golang.org/x/text@v0.3.7/internal/language/lookup.go:76:7, interface conversion: interface {} is string, not int 2022/11/28 14:15:41 warning: failed to evaluate const intSize at /usr/local/go/src/strconv/atoi.go:52:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const intSize at /usr/local/go/src/strconv/atoi.go:52:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const uintSize at /usr/local/go/src/strconv/decimal.go:106:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const uintSize at /usr/local/go/src/strconv/decimal.go:106:7, runtime error: negative shift amount 2022/11/28 14:15:41 warning: failed to evaluate const intBits at /usr/local/go/src/fmt/scan.go:939:2, runtime error: negative shift amount 2022/11/28 14:15:41 create docs.go at docs/docs.go 2022/11/28 14:15:41 create swagger.json at docs/swagger.json 2022/11/28 14:15:41 create swagger.yaml at docs/swagger.yaml
This is helpful to me, thank you
This also happened to me. There doesn't seem to be a reason really. We compile swagger in our PR pipeline and it happens across multiple services since last week. On my machine it works like a charm.
As the most basic example, we had a pr changing the string value of a const somewhere in the code and the error occurred.
Maybe the trace is useful:
goroutine 1 [running]:
[1094](https://github.com/myproject/actions/runs/3572921232/jobs/6006373826#step:4:1112)
github.com/swaggo/swag.(*PackageDefinitions).evaluateConstValue(0xc000e59180, 0xc00fcec720?, 0xc00fc9fc50?, {0xa2c0f0?, 0xc000e974d0?}, {0xa2a6e0, 0xc0000cb820}, 0x3?)
[1095](https://github.com/myproject/actions/runs/3572921232/jobs/6006373826#step:4:1113)
/home/runner/go/pkg/mod/github.com/swaggo/swag@v1.8.8/package.go:146 +0x101c
[1096](https://github.com/myproject/actions/runs/3572921232/jobs/6006373826#step:4:1114)
github.com/swaggo/swag.(*PackagesDefinitions).EvaluateConstValue(0xc00a3bf698?, 0xc000e59180, 0xc00fb62300, 0x0)
[1097](https://github.com/myproject/actions/runs/3572921232/jobs/6006373826#step:4:1115)
/home/runner/go/pkg/mod/github.com/swaggo/swag@v1.8.8/packages.go:282 +0x19d
[1098](https://github.com/myproject/actions/runs/3572921232/jobs/6006373826#step:4:1116)
github.com/swaggo/swag.(*PackagesDefinitions).evaluateAllConstVariables(...)
[1099](https://github.com/myproject/actions/runs/3572921232/jobs/6006373826#step:4:1117)
/home/runner/go/pkg/mod/github.com/swaggo/swag@v1.8.8/packages.go:265
[1100](https://github.com/myproject/actions/runs/3572921232/jobs/6006373826#step:4:1118)
github.com/swaggo/swag.(*PackagesDefinitions).ParseTypes(0xc0000cb820)
[1101](https://github.com/myproject/actions/runs/3572921232/jobs/6006373826#step:4:1119)
/home/runner/go/pkg/mod/github.com/swaggo/swag@v1.8.8/packages.go:110 +0x254
[1102](https://github.com/myproject/actions/runs/3572921232/jobs/6006373826#step:4:1120)
github.com/swaggo/swag.(*Parser).ParseAPIMultiSearchDir(0xc000194000, {0xc000151fe0?, 0x1?, 0x0?}, {0x7ffc65965d2b?, 0x25?}, 0x2)
[1103](https://github.com/myproject/actions/runs/3572921232/jobs/6006373826#step:4:1121)
/home/runner/go/pkg/mod/github.com/swaggo/swag@v1.8.8/parser.go:375 +0x3bf
[1104](https://github.com/myproject/actions/runs/3572921232/jobs/6006373826#step:4:1122)
github.com/swaggo/swag/gen.(*Gen).Build(0xc00015d9b0, 0xc0001562a0)
[1105](https://github.com/myproject/actions/runs/3572921232/jobs/6006373826#step:4:1123)
/home/runner/go/pkg/mod/github.com/swaggo/swag@v1.8.8/gen/gen.go:182 +0x637
[1106](https://github.com/myproject/actions/runs/3572921232/jobs/6006373826#step:4:1124)
main.initAction(0xc000182780?)
[1107](https://github.com/myproject/actions/runs/3572921232/jobs/6006373826#step:4:1125)
/home/runner/go/pkg/mod/github.com/swaggo/swag@v1.8.8/cmd/swag/main.go:158 +0x7bd
[1108](https://github.com/myproject/actions/runs/3572921232/jobs/6006373826#step:4:1126)
github.com/urfave/cli/v2.(*Command).Run(0xc000131320, 0xc0001764c0)
[1109](https://github.com/myproject/actions/runs/3572921232/jobs/6006373826#step:4:1127)
/home/runner/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/command.go:163 +0x5bb
[1110](https://github.com/myproject/actions/runs/3572921232/jobs/6006373826#step:4:1128)
github.com/urfave/cli/v2.(*App).RunContext(0xc0001589c0, {0xa2cf08?, 0xc0000bc000}, {0xc0000b8000, 0xa, 0xa})
[1111](https://github.com/myproject/actions/runs/3572921232/jobs/6006373826#step:4:1129)
/home/runner/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:313 +0xb48
[1112](https://github.com/myproject/actions/runs/3572921232/jobs/6006373826#step:4:1130)
github.com/urfave/cli/v2.(*App).Run(...)
[1113](https://github.com/myproject/actions/runs/3572921232/jobs/6006373826#step:4:1131)
/home/runner/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:224
[1114](https://github.com/myproject/actions/runs/3572921232/jobs/6006373826#step:4:1132)
main.main()
[1115](https://github.com/myproject/actions/runs/3572921232/jobs/6006373826#step:4:1133)
/home/runner/go/pkg/mod/github.com/swaggo/swag@v1.8.8/cmd/swag/main.go:229 +0x55d
@AdrianCio Hi, sorry to have made this bug. Enums invole a lot of const evaluation, and many cases to be considered. It is to be pefected gradually. @faustfu-WaveGIS has provided useful imformation about panic to me, and I have made an effort to fix it by PR #1440.
Don't worry about it, I wanted to provide as much info as I could to help in figuring out a solution :D
Great to see a fix is already in master @sdghchj when do you think we will get a release for that ?
@AdrianCio, we are releasing a new version every month. The latest version was released 7 days ago, so you can do the maths.
Meanwhile, you can test by building swag from the source.
we are releasing a new version every month.
Wonder how many folks, like myself, just pinned their version to 1.8.7 and will never upgrade it again.
Pretty strange to release a broken stable
release and for no clear (nor rationale) reason refuse to release any hotfix simply saying to wait until the next regularly scheduled release.
@AdrianCio, we are releasing a new version every month. The latest version was released 7 days ago, so you can do the maths.
Meanwhile, you can test by building swag from the source.
This is an awful decision to be made by a developer of something used by others. If the team completely breaks a stable release which forces people to rollback, its ok shit happens. If the teams answer is we only release once a month, do the math.. that is ridiculous and pathetic from a developer.
Forcing people to build from source (with other potentially breaking things) in their live environments is also a stupid solution for more than just testing.
Just cut a patch release to fix your screw up, why is that not even considered before telling people to "you can do the maths"
that is ridiculous and pathetic from a developer.
Please don't be rude, they are volunteer developers that don't owe you anything.
And remember, you can simply go install github.com/swaggo/swag@master
.
It might be rude but it is true. As a dev, if i completely break something that people rely on (i made the choice to give my time and break it, i will make the choice to spend my time and fix it as that is the right thing to do) i am saying this from a standpoint of making people wait instead of releasing a patch is absurd and it is.
And remember, consumers are not GO devs and should not be expected/forced to build and run from source as i already stated.
I totally get people make mistakes, hell i do it all the time! I also have the expectation if something gets completely broken (not just a small thing) it should be fixed. I expect that from myself as well.
@AdrianCio, we are releasing a new version every month. The latest version was released 7 days ago, so you can do the maths.
Meanwhile, you can test by building swag from the source.
How about Bugfix/Patch releases come out ASAP while feature release following regular cadence? Are you going to say same thing when another CVE appears in the wild and you're gonna be like "do the maths"? Dude
And remember, you can simply go install github.com/swaggo/swag@master.
Oh thanks for the hint. 🚀
I agree that a release should be made, but you can ask nicely and not call devs "pathetic" when they are spending their free time to bring us such a highly useful project. Being an OSS maintainer is hard enough.
so you can do the math
and expecting users to build from source are really the only rude comments here.
but in the interest of not derailing the conversatoin
to be clear: there are no plans to ever have an off-cycle release even for critical breaking bugs or CVEs?
That's beyond any words if that is the case. Rude, unprofessional, unethical, and a generally dick move are some terms that come to mind.
I agree that a release should be made, but you can ask nicely and not call devs "pathetic" when they are spending their free time to bring us such a highly useful project. Being an OSS maintainer is hard enough.
Bud, I said the decision.. Not the dev.
I am well aware the crap OSS devs deal with & this is all about the decision to not patch it for 3 weeks
Bud, I said the decision.. Not the dev.
I am well aware the crap OSS devs deal with & this is all about the decision to not patch it for 3 weeks
Staying polite and benevolent in all circumstances and for all, prevent to avoid extreme and negative decisions being taken by a confusion of understanding.
@AdrianCio, we are releasing a new version every month. The latest version was released 7 days ago, so you can do the maths. Meanwhile, you can test by building swag from the source.
This is an awful decision to be made by a developer of something used by others. If the team completely breaks a stable release which forces people to rollback, its ok shit happens. If the teams answer is we only release once a month, do the math.. that is ridiculous and pathetic from a developer.
Forcing people to build from source (with other potentially breaking things) in their live environments is also a stupid solution for more than just testing.
Just cut a patch release to fix your screw up, why is that not even considered before telling people to "you can do the maths"
Thanks for all the appreciation and the good words.
It's not about releasing now a new version. This timeframe between releases allows people to test new code to open issues.
But I guess you are testing in production.
How about Bugfix/Patch releases come out ASAP while feature release following regular cadence? Are you going to say same thing when another CVE appears in the wild and you're gonna be like "do the maths"? Dude
Are u serious? This is not a security issue. If you allow me I will call it a breaking feature :smile:
But I guess you are testing in production.
I think the swaggo team and the community have completely different definitions of what a new stable
release is.
If the release is not stable and production ready as you claim then it should NOT be tagged as latest
implying a stable release and should be tagged as pre-release
for beta testing.
GitHub clearly notes that when creating a release as well.
If your releases are not production ready - as you said given saying users are testing in production - why is the team failing to mark them as NOT production ready and lying to the community?
That's extremely poor development practice.
But I guess you are testing in production.
I think the swaggo team and the community have completely different definitions of what a new
stable
release is.If the release is not stable and production ready as you claim then it should NOT be tagged as
latest
implying a stable release and should be tagged aspre-release
for beta testing.That's extremely poor development practice.
I agree with you regarding this matter. We should be more organized here. We made mistakes, and we will possibly do more.
But it would be best if you respected the time and effort invested by contributors and maintainers. After all, you never contributed to this project, but I guess you are using it.
Contribution is not only about pushing codes. We are all here contributing to the project by discussing things, submitting bugs, using and advocating it on the internet. If release cadence is about baking and testing latest changes, I suggest you to read what the release candidate is. ;)
Good luck.
If the current stable
isn't stable why not pull the build back? Would it cause too much trouble on your end?
advocating
Contribution is not only about pushing codes. We are all here contributing to the project by discussing things, submitting bugs, using and advocating it on the internet. If release cadence is about baking and testing latest changes, I suggest you to read what the release candidate is. ;)
Good luck.
That's funny. If we had gone by the book, we probably didn't advance from v1.0.0 due to the bugs we go through after each release.
I'm doing this maintenance for the benefit of the community in my free time. And believe me, I can easily find better things to do.
I'm doing this maintenance for the benefit of the community in my free time. And believe me, I can easily find better things to do.
Sure go ahead, no one is forcing you. Just put the notice on the README and let's get done with this. That'd benefit the community.
Good luck.
advocating
Contribution is not only about pushing codes. We are all here contributing to the project by discussing things, submitting bugs, using and advocating it on the internet. If release cadence is about baking and testing latest changes, I suggest you to read what the release candidate is. ;)
Good luck.
That's funny. If we had gone by the book, we probably didn't advance from v1.0.0 due to the bugs we go through after each release.
I'm doing this maintenance for the benefit of the community in my free time. And believe me, I can easily find better things to do.
For me, This isn't about a bug being released, I mentioned that. This also isn't an attack on a dev or devs. My point of view was strictly about the decision made to leave this kinda bug in a (what I thought) was stable/latest release. It is not hard to patch and build, then rebase the current dev wth that set of changes but that wasn't even an option or thought. Live with this bug or build from source for 3 weeks was the answer.
You are commenting about running a dev in a live env and yet that is exactly what yall are using as the way to go forward for weeks.
https://github.com/swaggo/swag/releases/tag/v1.8.9-rc2 is out, let's try out and leave feedback please.
Describe the bug While running the init command with master it panics
To Reproduce Steps to reproduce the behavior:
const ( TypePerson Type = "person" TypeBusiness Type = "business" )
type customerIn struct { ClientId string
json:"client_id"
Type stringjson:"type"
}type customerOut struct { Id string
json:"id"
ClientId stringjson:"client_id"
Type stringjson:"type"
CreatedAt time.Timejson:"created_at"
UpdatedAt time.Timejson:"updated_at"
}type customersOut struct { Result []customerOut }
swag init -g service/server/server.go --pd swag fmt -g service/server/server.go
swag init -g service/server/server.go --pd 2022/11/22 08:09:45 Generate swagger docs.... 2022/11/22 08:09:45 Generate general API Info, search dir:./ 2022/11/22 08:09:45 warning: failed to get package name in dir: ./, error: execute go list command, exit status 1, stdout:, stderr:no Go files in /Users/nicolas.sassi/dev/soul/acaiah panic: runtime error: negative shift amount
goroutine 1 [running]: github.com/swaggo/swag.(PackageDefinitions).evaluateConstValue(0xc00607e870, 0xc0068aa2d0?, 0xc00665ef60?, {0x165bee0?, 0xc005cecf90?}, {0x165a460, 0xc0001b1800}, 0x1c?) /Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/package.go:146 +0x102b github.com/swaggo/swag.(PackagesDefinitions).EvaluateConstValue(0xc00479f698?, 0xc00607e870, 0xc00682de00, 0x0) /Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/packages.go:282 +0x19d github.com/swaggo/swag.(PackagesDefinitions).evaluateAllConstVariables(...) /Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/packages.go:265 github.com/swaggo/swag.(PackagesDefinitions).ParseTypes(0xc0001b1800) /Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/packages.go:110 +0x254 github.com/swaggo/swag.(Parser).ParseAPIMultiSearchDir(0xc00027c000, {0xc0002780e0?, 0x1?, 0x0?}, {0x7ff7bfeff555?, 0x18?}, 0x64) /Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/parser.go:375 +0x3bf github.com/swaggo/swag/gen.(Gen).Build(0xc000249950, 0xc0002502a0) /Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/gen/gen.go:182 +0x637 main.initAction(0xc000266780?) /Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/cmd/swag/main.go:158 +0x7bd github.com/urfave/cli/v2.(Command).Run(0xc000220ea0, 0xc000262300) /Users/nicolas.sassi/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/command.go:163 +0x5dc github.com/urfave/cli/v2.(App).RunContext(0xc000195d40, {0x165cef0?, 0xc000196008}, {0xc00019c000, 0x5, 0x5}) /Users/nicolas.sassi/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:313 +0xb7d github.com/urfave/cli/v2.(*App).Run(...) /Users/nicolas.sassi/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:224 main.main() /Users/nicolas.sassi/go/pkg/mod/github.com/swaggo/swag@v1.8.8-0.20221122034606-e5d507dd4727/cmd/swag/main.go:229 +0x5c5 make: *** [swagger] Error 2