This is a creation in Article, where the information may have evolved or changed.
Recent group of new project requirements with go to write, no way can only read the document side write code, today encountered depressed problem, check for a long time finally found incredibly is a punctuation caused, hence the record of
Just write unit tests for an interface to initialize a struct array, then iterate over the array and establish HTTP. Request for testing, the results have been error, and finally ... The correct posture of Golang structure initialization was found t_t
1Requests: =[]authrequest{2 authrequest{3 "Plain",4 "xl_test@xunlei.net",5 "123456",6 "SMTP",7 3,8 "192.168.34.104",9 "client.example.com",Ten }, One authrequest{ A "Plain", - "xl_test@xunlei.net", - "123456", the "POP3", - 3, - "192.168.34.104", - "client.example.com", + }, -}
The problem is that the last element in the curly brace must be followed by a comma, and Golang's strict syntax is a taste.