【发布时间】:2021-08-30 08:14:02
【问题描述】:
gorm 是否有类似 PHP 中的方法来执行此操作?
$name = $db->column("name");
// output of $name: ["joe", "john", .....]
print_r($name);
我想做什么(假代码):
var ct []string
db.Model("user").Column(&ct)
// output of ct: []string{"joe", "john", .....}
fmt.println(ct)
或者我必须使用 strcut 得到结果,然后格式化为切片?
gorm 版本:v1.21.11
【问题讨论】: