当前位置:网站首页>Problems and solutions of MacOS installation go SQLite3
Problems and solutions of MacOS installation go SQLite3
2022-06-23 22:33:00 【Wangxiaoming_ HIT】
If you download directly , An error is as follows :
go get github.com/mattn/go-sqlite3 go get: module github.com/mattn/go-sqlite3: reading https://athens.azurefd.net/github.com/mattn/go-sqlite3/@v/list: 504 Gateway Timeout
First step
Mac OS X 1. after Homebrewn install : html brew install pkgconfig brew install sqlite3
The results are as follows :
* ~ brew install pkgconfig Warning: pkg-config 0.29.2_3 is already installed and up-to-date. To reinstall 0.29.2_3, run: brew reinstall pkg-config * ~ brew install sqlite3 Warning: sqlite 3.37.0 is already installed and up-to-date. To reinstall 3.37.0, run: brew reinstall sqlite
The second step
brew link pkgconfig --force brew link sqlite3 --force
The third step
go get github.com/mattn/go-sqlite3
give the result as follows :
go: downloading github.com/mattn/go-sqlite3 v1.14.9
sqllite The test case
package mysql
import (
"fmt"
"testing"
"github.com/jinzhu/gorm"
//_ "github.com/jinzhu/gorm/dialects/sqlite"
_ "github.com/mattn/go-sqlite3"
)
type Product struct {
gorm.Model
Code string
Price uint
}
func (Product) TableName() string {
return "hax_products"
}
func Test(t *testing.T) {
db, err := gorm.Open("sqlite3", "test.db")
if err != nil {
panic("failed to connect database")
}
defer db.Close()
gorm.DefaultTableNameHandler = func(db *gorm.DB, defaultTableName string) string {
return "hax_" + defaultTableName
}
db.LogMode(true)
// Migrate the schema
db.AutoMigrate(&Product{})
db.Create(&Product{Code: "L1212", Price: 1000})
var product Product
db.First(&product, 1)
var products []Product
db.Find(&products)
fmt.Printf("Total count %d", len(products))
}macos There is a problem with the installation , You can refer to https://segmentfault.com/q/1010000000162180 This solution
Reference material
- https://www.shangmayuan.com/a/3b17868c37bb4475a8b8c0f4.html
- https://www.cnblogs.com/go-ios/p/3871863.html
- go get github.com/mattn/go-sqlite3
- https://segmentfault.com/q/1010000000162180
边栏推荐
- PHP laravel 8.70.1 - cross site scripting (XSS) to cross Site Request Forgery (CSRF)
- API gateway monitoring function the importance of API gateway
- Using nodejs and Tencent cloud API to identify invoices
- Why is only one value displayed on your data graph?
- Micro build low code tutorial - variable definition
- What is dynamic registration? What is static registration?
- Dart series: smooth as silk, operating files and directories
- How does H5 communicate with native apps?
- How to create a virtual server through a fortress machine? What are the functions of the fortress machine?
- How to use xshell to log in to the server through the fortress machine? How does the fortress machine configure the tunnel?
猜你喜欢

为什么你的数据图谱分析图上只显示一个值?

Hackinglab penetration test question 8:key can't find it again

In the eyes of the universe, how to correctly care about counting East and West?

為什麼你的數據圖譜分析圖上只顯示一個值?

游戏安全丨喊话CALL分析-写代码

Game security - call analysis - write code

openGauss Developer Day 2022正式开启,与开发者共建开源数据库根社区

脚本之美│VBS 入门交互实战

Slsa: accelerator for successful SBOM

应用实践 | Apache Doris 整合 Iceberg + Flink CDC 构建实时湖仓一体的联邦查询分析架构
随机推荐
Why is only one value displayed on your data graph?
How to set the website address for website construction can the website be put on record
How does the fortress machine view the account assigned by the server? What are the specific steps?
How to create a virtual server through a fortress machine? What are the functions of the fortress machine?
How to batch output EAN13 code to PDF
TMUX support, file transfer tool Trz / Tsz (trzsz) similar to RZ / SZ
Integrated management and control system of 3D intelligent warehousing and logistics park
What are the steps required for TFTP to log in to the server through the fortress machine? Operation guide for novice
Beauty of script │ VBS introduction interactive practice
Tcapulusdb Jun · industry news collection
为什么你的数据图谱分析图上只显示一个值?
WordPress plug-in recommendation
Judge whether the target class conforms to the section rule
[vulnerability recurrence]log4j vulnerability rce (cve-2021-44228)
In the new easygbs kernel version, the intranet mapping to the public network cannot be played. How to troubleshoot?
Environment construction of go language foundation
Hackinglab penetration test question 8:key can't find it again
Deep understanding of leakcanary
How to solve the problem that the GPU VNC has two mice with large deviation
How to deploy the deep learning model to the actual project? (classification + detection + segmentation)