Home / golang

golang line break error: expected statement, found '.'

Posted on:2020-04-27 Views:9204 Words:78

When writing golang code, I encountered a line of code that was too long, so I habitually refer to PHP’s line break method.

info.AddField("Name", "name", db.Varchar)
      .FieldFilterable(types.FilterType{Operator: types.FilterOperatorLike})

However, when VIM saves, the triggered go fmt is incorrect.

expected statement, found ‘.’

After a quick reference to the open source project code on github, it turns out that the comma needs to be written on the top line.

info.AddField("Name", "name", db.Varchar).
       FieldFilterable(types.FilterType{Operator: types.FilterOperatorLike})