Skip to content

Build fails on linux/386: math.MaxUint32 overflows int #75

@whki

Description

@whki

Description:

When cross-compiling for linux/386 with CGO_ENABLED=0, the build breaks in package github.com/vadv/gopher-lua-libs/bit:

PS D:\Go\WorkSpace\rulego\examples\server\cmd\server> $env:GOOS="linux"; $env:GOARCH="386"; $env:CGO_ENABLED="0"; go build -tags "with_extend,with_ai,with_ci,with_iot,use_fasthttp" -o rulego-server-all-linux-i386 `

github.com/vadv/gopher-lua-libs/bit

..........\pkg\mod\github.com\vadv\[email protected]\bit\api.go:81:9: math.MaxUint32 (untyped int constant 4294967295) overflows int

Root cause:

On 32-bit architectures, Go’s int type is only 32 bits signed, so the untyped constant math.MaxUint32 (4294967295) cannot be assigned to an int.

Suggested fix:

Replace the int variable/parameter with uint32 (or uint64) wherever math.MaxUint32 is used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions