200sc / bebop

bebop wire format in Go
Apache License 2.0
71 stars 5 forks source link

Messages containing dates produce incorrect GO syntax #2

Closed ghost closed 3 years ago

ghost commented 3 years ago
message MyObj {
    1 -> date Start;
    2 -> date End;
}

Results in code such as:

iohelp.WriteInt64Bytes(buf[at:], (*bbp.Start.UnixNano()/100)) iohelp.WriteInt64Bytes(buf[at:], (*bbp.End.UnixNano()/100))

golangci-lint run my_obj.go

level=error msg="[linters context] typechecking error: my_obj.go:87:27: invalid operation: cannot indirect bbp.Start.UnixNano() (value of type int64)"
level=error msg="[linters context] typechecking error: my_obj.go:95:27: invalid operation: cannot indirect bbp.End.UnixNano() (value of type int64)"
200sc commented 3 years ago

On it, thank you for the report.

ghost commented 3 years ago

Also, is the "tick" concept and hence the division by 100 really necessary?

200sc commented 3 years ago

Unfortunately the 'tick' logic is necessary to keep compatibility with the standard: https://github.com/RainwayApp/bebop/wiki/Wire-format#dates Otherwise generated messages could fail to be parsed by other bebop parsers.

I'm not particularly fond of it myself.

ghost commented 3 years ago

@200sc makes sense. Thanks for the quick fix.