Golang is a programming language developed by Google that is statically strongly typed, compiled, concurrently typed, and has garbage collection capabilities. Int is a reserved keyword in golang. Let's take a look at the method of determining whether int is empty in golang.
Method 1:
First convert the int type data into the String type, and then determine whether the String type data is empty.
Sample code:
int point; String val=point +""; if("".equals(val)){ // do something... }
PS: int point is not an object, and the default is 0 when the int type is empty.
Method 2:
If point is of type int, the result obtained cannot be null.
If no field is inserted when inserting a piece of data, and the default value in the database is null, you can use
Integer point= GiftInfo.getPoints();
and then determine whether point is equal to null.
Sample code:
Integer point= GiftInfo.getPoints(); if(point == null){ // do something... }
For more golang knowledge, please pay attention to the golang tutorial column on the PHP Chinese website.
The above is the detailed content of How to determine whether int is empty in Golang. For more information, please follow other related articles on the PHP Chinese website!