skip to content
Alvin Lucillo

Go unkeyed fields and Cypress wait

/ 1 min read

💻 Tech

One of the go vet findings I fixed today is about ‘unkeyed fields’ in a struct literal. Go vet is detects parts of the code that doesn’t adhere to the best practices. Not adhering to the recommended practices may lead to bugs or unintended behavior. Here’s an example of where unkeyed fields is detected:

type Person struct {
    Name string
    Age  int
}

func main() {
    p := Person{"Blorb", 30}
    fmt.Println(p)
}

Although the code runs, it’s better to use the key-value pair when initializing a struct to make it more readable and maintainable.

Another things I learned also is to use cy.wait(1000) in cypress to give some time for a task to complete like downloading a file. One thing I noticed is even without cy.wait(1000), test job in the CI/CD pipeline still passes. I’m not sure why yet, but for local test purposes, I use cy.wait(1000).