The _____ keyword is used to create a new instance of a struct in Go

  • new
  • make
  • struct
  • instance
The struct keyword is used to create a new instance of a struct in Go. For example, if you have a struct type defined as type Person struct { Name string }, you can create a new instance like this: p := Person{Name: "John"}. The new keyword is used to allocate memory for a variable and return a pointer to it, make is used for slices, maps, and channels, and instance is not a valid Go keyword for creating structs.
Add your answer
Loading...

Leave a comment

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