当前位置:网站首页>Go operation SQLite code error
Go operation SQLite code error
2022-06-24 06:57:00 【CSDN Q & A】
The phenomenon and background of the problem
Want to learn how to use Go operation SQLite database
Problem related code , Do not paste screenshots
package mainimport ( "gorm.io/driver/sqlite" "gorm.io/gorm")type LogStatistics struct { gorm.Model logStatisticsId string topVisitArticleList string topCoastTimeRequestList string createTime int64 updateTime int64}func main() { db, err := gorm.Open(sqlite.Open("file::memory:?cache=shared"), &gorm.Config{}) if err != nil { panic("failed to connect database") } // transfer schema err = db.AutoMigrate(&LogStatistics{}) if err != nil { return } // Create db.Create(&LogStatistics{topVisitArticleList: "00", topCoastTimeRequestList: "xx"}) // Read var logStatistics LogStatistics // Find by integer primary key db.First(&logStatistics, 1) // lookup code The field values for D42 The record of db.First(&logStatistics, "topVisitArticleList = ?", "00") //// Update - take logStatistics Of price Updated to 200 //db.Model(&logStatistics).Update("Price", 200) //// Update - Update multiple fields //db.Model(&logStatistics).Updates(Product{Price: 200, Code: "F42"}) // Update only non-zero value fields //db.Model(&logStatistics).Updates(map[string]interface{}{
"Price": 200, "Code": "F42"}) // //// Delete - Delete logStatistics //db.Delete(&logStatistics, 1)}Operation results and error reporting contents
GOROOT=D:\ProgramData\GOPATH\go1.17.7 #gosetupGOPATH=D:\ProgramData\GOPATH #gosetupD:\ProgramData\GOPATH\go1.17.7\bin\go.exe build -o C:\Users\HP\AppData\Local\Temp\GoLand\___go_build_admin_data_show.exe admin_data_show #gosetup# github.com/mattn/go-sqlite3cc1plus.exe: warning: command line option '-std=gnu99' is valid for C/ObjC but not for C++_cgo_export.c: In function 'void _cgo_1ad64cd63b8b_Cfunc__Cmalloc(void*)':_cgo_export.c:233:53: error: invalid conversion from 'void*' to '_cgo_1ad64cd63b8b_Cfunc__Cmalloc(void*)::<unnamed struct>*' [-fpermissive] } __attribute__((__packed__, __gcc_struct__)) *a = v;Compilation finished with exit code 2My solution ideas and tried methods
According to some online tutorials : Try installing https://jmeubank.github.io/tdm-gcc/articles/2021-05/10.3.0-release Of GCC Program , useless , The error is still reported
Go beginner , There's no way to start
What I want to achieve
Run normally and be able to operate the database
Take the answer :
From the wrong information , Is used by C++ Compiler compilation C Caused by documents . stay C In language ,void * Type can be implicitly converted to other pointer types , When in C++ The conversion must be displayed in the .
Solve this problem , You can specify to use C Compiler to compile C file , For example, use gcc compiler
go env -w "CC=gcc.exe"边栏推荐
- 雲監控系統 HertzBeat v1.1.0 發布,一條命令開啟監控之旅!
- 华为云低时延技术的九大绝招
- Easyrtc call error `failed to execute'send'on'rtcdatachannel'
- Online font converter what is the meaning of font conversion
- About Stacked Generalization
- On BOM and DOM (4): dom0/dom2 event handling analysis
- 【问题解决】虚拟机配置静态ip
- Go excel export tool encapsulation
- Kangaroo cloud: the overall architecture and key technical points of building a real-time computing platform based on Flink
- Thread safety and its implementation
猜你喜欢

Record -- about the method of adding report control to virtual studio2017 -- reportview control
![[JUC series] completionfuture of executor framework](/img/d0/c26c9b85d1c1b0da4f1a6acc6d33e3.png)
[JUC series] completionfuture of executor framework

网吧管理系统与数据库

【二叉树】——二叉树中序遍历

Rockscache schematic diagram of cache operation

Leetcode: Sword finger offer 26: judge whether T1 contains all topologies of T2

潞晨科技获邀加入NVIDIA初创加速计划

leetcode:84. The largest rectangle in the histogram

数据同步工具 DataX 已经正式支持读写 TDengine
![跳跃游戏II[贪心练习]](/img/e4/f59bb1f5137495ea357462100e2b38.png)
跳跃游戏II[贪心练习]
随机推荐
原神方石机关解密
File system notes
On BOM and DOM (6): bit value calculation of DOM objects and event objects, such as offsetx/top and clearx
Interpreting the new features of Appstore: Customizing product pages and a/b test tools
What is the role of domain name websites? How to query domain name websites
"Adobe international certification" in the design industry, why can't big but big designs have good results?
The data synchronization tool dataX has officially supported reading and writing tdengine
Jumping game ii[greedy practice]
Easyscreen live streaming component pushes RTSP streams to easydss for operation process sharing
How to send SMS in groups? What are the reasons for the poor effect of SMS in groups?
Spirit information development log (1)
Source code analysis of current limiting component uber/ratelimit
Produce kubeconfig with permission control
I want to say "three no" to digital transformation
缓存操作rockscache原理图
35 year old crisis? It has become a synonym for programmers
leetcode:剑指 Offer 26:判断t1中是否含有t2的全部拓扑结构
Programmers use personalized Wallpapers
Tencent launched the "reassuring agricultural product plan" to support 100 landmark agricultural product brands!
Kangaroo cloud: the overall architecture and key technical points of building a real-time computing platform based on Flink