type Ptr struct {
ID *big.Int
IpAddress string
Port string
}
var NewVar Ptr
After initializing the NewVar with values I then want to set NewVar to nil. How can I do this?
type Ptr struct {
ID *big.Int
IpAddress string
Port string
}
var NewVar Ptr
After initializing the NewVar with values I then want to set NewVar to nil. How can I do this?
The zero value of a struct value is not nil
Each element of such a variable or value is set to the zero value for its type:
false
for booleans,0
for integers,0.0
for floats,""
for strings, andnil
for pointers, functions, interfaces, slices, channels, and maps.
In your case, this variable declaration var NewVar Ptr
creates the variable, binds corresponding identifier Ptr
to it, and gives it a type and an initial value.