ravendb / ravendb-go-client

MIT License
39 stars 16 forks source link

facet_options -> Constant 9223372036854775807 overflows int #161

Closed bobmcallan closed 3 years ago

bobmcallan commented 3 years ago

Hello,

I'm switching from c# to golang and have followed (mostly) the examples you have with this repo. However receive a compile time error.

....\pkg\mod\github.com\ravendb\ravendb-go-client@v0.0.0-20201105141604-5ff65ecb1354\facet_options.go:25:12: constant 9223372036854775807 overflows int

My model is the same as the northwind example, so I'm not sure how this error is generated.

// Company struct type Company struct { ID string Name string json:"Name" ExternalID string json:"ExternalId" Phone string json:"Phone,omitempty" Fax string json:"Fax,omitempty" }

Regards, Bob

ayende commented 3 years ago

What Go version are you using? Are you compiling in 32 bits mode?

The relevant error is here:

https://github.com/ravendb/ravendb-go-client/blob/master/facet_options.go#L25

But this is expected to work because it will cast the value.

bobmcallan commented 3 years ago

go version go1.16.1 windows/amd64

Bob

bobmcallan commented 3 years ago

I've specifically set the ARCH to 64, and it compiles.

$env:GOOS="windows"; $env:GOARCH="amd64";

Thanks, Bob

jazzjackrabb1t commented 3 years ago

I face this problem when building on an armv7l. The problem is int pointer cannot hold int64 max on 32 bit arch. https://github.com/golang/go/issues/23086

Changing the int to int64 solves the problem for 32 bit arm.

func maxInt() int64 { if unsafe.Sizeof(int(0)) == unsafe.Sizeof(int32(0)) { return int64(math.MaxInt32) } return int64(math.MaxInt64) }

ayende commented 3 years ago

Am I missing something here? We are returning the value based on the size of int. How come int is not 32 bits but can't store max int64?