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

Updated at: 2020-04-27 Views: 1742 Words: 78 Category: golang

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})

Leave a Comment