Error: struct Type is not an expression

The error is on this line

    var s = Salutation

The thing to the right of the = must evaluate to a value. Salutation is a type, not value. Here are three ways to declare s:

 var s Salutation      // variable declaration using a type 

 var s = Salutation{}  // variable declaration using a value

 s := Salutation{}     // short variable declaration

The result of all three declarations is identical. The third variation is usually preferred to the second, but cannot be used to declare a package-level variable.

See the language specification for all of the details on variable declarations.

The variable declaration and field initializations can be combined into a single statement:

 var s = Salutation{name: "Alex", greeting: "Hello"} // variable declaration

 s := Salutation{name: "Alex", greeting: "Hello"}    // short variable declaration

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)