gostructvar

Difference between var Foo struct and type Foo struct


I have hard time to understand what is the diffrence between:

var requestPayLoad struct {
        Email string `json:"email"`
        Password string `json:"string"`
    }

and:

type jwtUSer struct {
    ID        int    `json:"id"`
    FirstName string `json:"first_name"`
    LastName  string `json:"last_name"`
}

one is type and one is a var.


Solution

  • In both cases type T may be a named or an unnamed (anonymous) type.