Avoid structures initializations with unamed fields

Why you should care

You should almost always specify field names when initializing structs. This is now enforced by go vet.

How we detect

CAST Highlight counts one occurrence each time a struct field has no name, except when init concerns an array.


// bad
func foo {
     // local var
     k := User{"John", "Doe", true}
my_function(User{"Joe", "Bidon", true})
func bar {
    k := User{
        FirstName: "John",
        LastName: "Doe",
        Admin: true,
func toto() {
     sig = append(sig, common.LeftPadBytes([]byte{64}, 32)...)
     tab = []String{“s1”, “s2”, “s3}



About CAST and Highlight’s Code Insights

Over the last 25 years, CAST has leveraged unique knowledge on software quality measurement by analyzing thousands of applications and billions of lines of code. Based on this experience and community standards on programming best practices, Highlight implements hundreds of code insights across 15+ technologies to calculate health factors of a software.