Skip to content

Go Language

Precise Lose Between Float64 and Uint64

In astjson library, the lexer scans the number and stores the respective bytes. Then the parser will parse the bytes to number which is expressed by a float64. It works well at beginning, however, once I added a corner case of number with value math.MaxUint64(1<<64 - 1 or decimal value 18446744073709551615), the parser cannot work as expected. It's indeed a bug issue.

The simplified problem is the value through debug of f is 18446744073709552000 instead of 18446744073709551615.

f, _ = strconv.ParseFloat("18446744073709551615", 64)

Developing Notes of ASTJSON Library

After reading about the compiler, I feel intrigued as it challenges me with numerous design and implementation details. It's an exciting topic for me. Inspired by the APIs the Haskell Aeson library exposed, it's a good practice for me to write a toy library named xieyuschen/astjson to parse JSON string to AST in a slightly functional way. This is a developing notes page, and I record some reflections.

Implementation Summary for gqlgen Request

GraphQL has wonderful features, the most charming features omparing to Restful API are:

  • nested query.
  • get the data nothing more.
  • explicated data type.

Here, I will take a deep look to know how these features are implemented. Before taking an eye in the framework code, we should make a reflection first, how could these features be implemented.