Go Function Return Values: List, Not Tuple
Recently, I suddenly found that the following code line is weird, how could it pass (int, error)
to ...any
?
Recently, I suddenly found that the following code line is weird, how could it pass (int, error)
to ...any
?
After learning briefly about compiler, with the motivation of walker
inside astjson, it's a bit compulsory to master some knowledge about symbol table as it helps to understand management of variables/states in a large different scales.
This blog talks first about the symbol table itself, and then check how Go
language maintains the values among contexts in src/context
. Note that it doesn't talk anything else rather than values in context.
Recently, my friend asked me a question, why inthe following go code, b
cannot be assigned to f
? With knowledges about AST, I got intrigue on it than ever before.
The failure is caused by Bar
and Foo
are not same type, hence, they cannot be assigned to each other. However, assign a string to Bar
or Foo
directly is valid.
This blog talks why the conversion fails and will introduce the type, type definition, properities of types with some examples.
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.
Our internal CLI tool will try to download a proto file by git achieve
command, and then tar it to /usr/local/include
. One user reported in his desktop tar cannot unzip file:
xxx.proto: Can't create 'xxx.proto'
tar: Error exit delayed from previous errors.
ERROR fail to extract xxx.proto into '/usr/local/include/xxx.proto'
via this script: 'tar -xf xxx.tar -C /usr/local/include'.