What is the zero value of a struct in Go?

  • The struct with all fields initialized to zero values
  • The struct with all fields set to 0
  • The struct with all fields set to nil
  • The struct with no fields initialized
In Go, the zero value of a struct is a struct with all fields initialized to their respective zero values. This means numeric fields are set to 0, strings are set to "", and pointers are set to nil.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *