<p>I'm currently writing a program to query a database, store the results (most likely insert them into a new table) and then compare results I.e., I'll perform a query and store results, then requery an hour later and compare the results from an hour ago to check for changes.</p>
<p>I built structs for the tables such that:</p>
<pre><code>type table1 struct {
id int
col1 string
col2 time.Time
}
type table2 struct{
id int
col1 string
col2 time.Time
}
</code></pre>
<p>I'm struggling with how to store the multiple row values into a struct in the simplest manner, then call it back and compare a field. I'll be comparing a specific field such as if t1.col1 == t2.col1 then check to see if this other field matches.</p>
<p>I'm not exactly sure how to store multiple rows into my struct easily though and then write it into a new table. So far I've figured that I'd use a slice of struct but I'm a little confused as to where to go from there/how to scan it in properly. I hope this is elaborated clearly. Thanks! </p>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
0 回复
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传