如何将golang类型结构中的列类型定义为longtext?

how to define column type in golang type struct as longtext?

我有这个安宁的代码:

type Post struct {
    Id      int64 `db:"post_id"`
    Created int64
    Title   string `form:"Title"`
    Body    string `form:"Body" binding:"required"`

}

但这让我只有 255 个 varchar 用于 Body。 我怎样才能将它设置为长文本?

这是来自马提尼框架的示例应用程序。

go 中字符串的最大长度肯定比 255 大很多。如果你看 this code:

myPost := Post{
  Id: 43,
  Created: 324,
  Title: "title",
  Body: "very long string",
}
fmt.Println(myPost.Body)
fmt.Println()
fmt.Println(len(myPost.Body))

你会看到一个字符串的输出和长度明显大于 255。所以要么你将它保存到数据库,这会截断它,要么我宁愿创建一个很好的可重现的例子。