go database/sql/driver driver.Value的作用
import (
"database/sql/driver"
"encoding/json"
"github.com/sirupsen/logrus"
"sshfortress/util"
)
type HardwareInfo struct {
Disk string `json:"hi_disk"`
Mem string `json:"hi_mem"`
NetCard string `json:"hi_net_card"`
Cpu string `json:"hi_cpu"`
System string `json:"hi_system"`
Login string `json:"hi_login"`
Ps string `json:"hi_ps"`
Port string `json:"hi_port"`
}
func (o HardwareInfo) Value() (driver.Value, error) {
b, err := json.Marshal(o)
return string(b), err
}
func (o *HardwareInfo) Scan(input interface{}) error {
return json.Unmarshal(input.([]byte), o)
}
分类:
GO
· 全网最简单!3分钟用满血DeepSeek R1开发一款AI智能客服,零代码轻松接入微信、公众号、小程
· .NET 10 首个预览版发布,跨平台开发与性能全面提升
· 《HelloGitHub》第 107 期
· 全程使用 AI 从 0 到 1 写了个小工具
· 从文本到图像:SSE 如何助力 AI 内容实时呈现?(Typescript篇)
2021-04-07 ansible playbook -include
2021-04-07 Ansible Playbook循环语句
2021-04-07 ansible非role格式
2021-04-07 ansible playbook如何处理错误(block-rescue-always)
2021-04-07 ansible 批量更新 nginx 配置,以及失败时的自动回滚样例
2021-04-07 systemctl启动服务时,配置日志输出控制