4

发现个 pure go 的 sqlite 驱动

 3 years ago
source link: https://www.v2ex.com/t/796538
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
发现个 pure go 的 sqlite 驱动

V2EX  ›  Go

发现个 pure go 的 sqlite 驱动

  iyear · 1 天前 · 1340 次点击

源于 tg 群群友的推荐

文档: https://pkg.go.dev/modernc.org/sqlite 而且还有相应的 gorm 的驱动:https://github.com/cloudquery/sqlite

这样似乎用不到 cgo 了,而且 goreleaser 什么的好像都能跑

有没有人用过这个库,性能什么的差别大吗?如果不错的话感觉挺香的

19 条回复    2021-08-19 22:18:00 +08:00

Smash

Smash   1 天前 via Android

cgo 对于交叉编译一点都不友好

meshell

meshell   1 天前   ❤️ 1

iyear

iyear   1 天前

@Smash #1 深有感触,搞分发的时候人都麻了

Smash

Smash   1 天前 via Android

@Smash 不仅如此,反而很多开发者引以为乐。觉得这样挺好的。

gamexg

gamexg   1 天前

Smash

Smash   1 天前   ❤️ 2

我有一个项目,用了 cgo 版本的 sqlite,CGO 是 ENABLE=1,在 docker 环境下的 alpine 上跑不起来。

用 file 命令查看可执行文件,发现是动态链接,很多 alpine 的动态链接库不兼容,最后需要改为静态链接。

最后加上 -linkmode "external" -extldflags "-static" 的 ldflag 参数才搞定。

keepeye

keepeye   1 天前

希望能发展壮大 讨厌 cgo

danc

danc   1 天前

大佬可以试试这个,我前几天试了下这个,但没有详细测试。这个库的大佬挺厉害,搞了一个 gcc 到 go 的编译器,然后把 sqlite 的 c 源码,编译成了 go 。

danc

danc   1 天前

https://gitlab.com/cznic/ccgo/-/blob/master/v3/main.go

```
//TODO parallel

//TODO CPython
//TODO Cython
//TODO gmp
//TODO gofrontend
//TODO gsl
//TODO gtk
//TODO hdf5
//TODO minigmp
//TODO mpc
//TODO mpfr
//TODO pcre
//TODO pcre2
//TODO quickjs
//TODO redis
//TODO tcl/tk
//TODO wolfssl
//TODO zdat
//TODO zlib
```

danc

danc   1 天前

上面有口误,是“c 到 go”的编译器

caotian

caotian   1 天前

挺好, 之前有个项目用到 sqlite, mac 上不能运行, 不能编译, 没办法把源码拷到服务器上编译

qieqie

qieqie   1 天前

这个作者挺厉害的,不过他很多项目实验性比较强,我是不敢用

qieqie

qieqie   1 天前

你们抱怨的 cgo 问题,换了 c/c++一样会遇到,和 cgo 就没啥关系,
而且你以为你静态链接了所有依赖,其实没有,不信可以试试`gethostbyname`

kekeabab

kekeabab   7 小时 30 分钟前

至少这个库,我觉得交叉编译很友好呀

GOOS=linux GOARCH=arm64 go build -x -trimpath -a -ldflags '-extldflags "-static -fpic -s -w"' .

环境是
archlinux 5.13.10-arch1-1 linux/amd64 x86_64
go version go1.17

iyear

iyear   5 小时 28 分钟前

@kekeabab #16 我发的这个?这个纯 go 搞的交叉编译当然舒服

kekeabab

kekeabab   5 小时 3 分钟前

@iyear 当然不是你发这个

关于   ·   帮助文档   ·   FAQ   ·   API   ·   我们的愿景   ·   广告投放   ·   感谢   ·   实用小工具   ·   1291 人在线   最高记录 5497   ·  

创意工作者们的社区

World is powered by solitude

VERSION: 3.9.8.5 · 15ms · UTC 17:45 · PVG 01:45 · LAX 10:45 · JFK 13:45
♥ Do have faith in what you're doing.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK