golang:将类型struct设置为nil [关闭]

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, and nil 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.