当前位置:网站首页>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"边栏推荐
- 基于三维GIS系统的智慧水库管理应用
- Game website making tutorial and correct view of games
- Programmers use personalized Wallpapers
- Nine possibilities of high CPU utilization
- How to operate the little red book account: making good use of the theory of long tail words
- Application configuration management, basic principle analysis
- Talk about how to dynamically specify feign call service name according to the environment
- puzzle(019.1)Hook、Gear
- Station B collapsed. Let's talk to the injured programmers
- Oracle case: ohasd crash on AIX
猜你喜欢

35岁危机?内卷成程序员代名词了

oracle sql综合运用 习题

Database stored procedure begin end

The data synchronization tool dataX has officially supported reading and writing tdengine

Challenges brought by maker education to teacher development

Nine unique skills of Huawei cloud low latency Technology

Record -- about the problem of garbled code when JSP foreground passes parameters to the background

File system notes

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

Oracle SQL comprehensive application exercises
随机推荐
云上本地化运营,东非第一大电商平台Kilimall的出海经
In the half year, there were 2.14 million paying users, a year-on-year increase of 62.5%, and New Oriental online launched its private domain
FreeRTOS MPU使系统更健壮!
原神方石机关解密
【JUC系列】Executor框架之CompletionFuture
多传感器融合track fusion
When the VPC main network card has multiple intranet IP addresses, the server cannot access the network internally, but the server can be accessed externally. How to solve this problem
On BOM and DOM (3): DOM node operation - element style modification and DOM content addition, deletion, modification and query
Do you want to research programming? I got six!
leetcode:84. The largest rectangle in the histogram
Actual combat | how to deploy flask project using wechat cloud hosting
解读AI机器人产业发展的顶层设计
开源与创新
CloudCompare&PCL 点云裁剪(基于裁剪盒)
Application configuration management, basic principle analysis
Overview of cloud computing advantages of using cloud computing
35 year old crisis? It has become a synonym for programmers
What is the role of domain name websites? How to query domain name websites
Raspberry PI (bullseye) replacement method of Alibaba cloud source
你有一个机会,这里有一个舞台