chai2010 / gopherchina2018-cgo-talk Goto Github PK
View Code? Open in Web Editor NEW:book: GopherChina2018: 深入CGO编程 - 最新修订
Home Page: https://chai2010.github.io/gopherchina2018-cgo-talk/
License: BSD 3-Clause "New" or "Revised" License
:book: GopherChina2018: 深入CGO编程 - 最新修订
Home Page: https://chai2010.github.io/gopherchina2018-cgo-talk/
License: BSD 3-Clause "New" or "Revised" License
根据大纲, 每个部分重点选择1-2个
// int32 => *C.char
var x = int32(9527)
var p *C.char = (*C.char)(unsafe.Pointer(&x))
// *C.char => int32
var q int32 = *(*int32)(unsafe.Pointer(p))
Note that both conversions must appear in the same expression, with only the intervening arithmetic between them:
// INVALID: uintptr cannot be stored in variable
// before conversion back to Pointer.
u := uintptr(p)
p = unsafe.Pointer(u + offset)
首页有背景图
我看过最新版的了,感觉这次又多了很多内容啊:)我这边目前能看出来的就是第六章类型转换里页面的顺序有点别扭,比如说第一页是说都有哪些可能的类型转换,然后三页开始介绍unsafe(我觉得第4页放在2和3前头好些?),然后一页是字符串和切片的结构,然后就是各种实战了,当然干货很多,但是是不是按照一个递进的顺序来好一些?比如基础类型是如何对应的,字符串是如何对应的(以及手动申请和释放内存),结构体类型还有最重要的指针类型。当然这个是我从一个cgo初学者的角度来看的,不确定和你演讲的场景是否一致
感谢 @julykobe
make-clib-static 文件夹
在windows Cygwin64 Terminal执行make命令报错
$ make
go build -buildmode=c-archive -o number.a
gcc_libinit_windows.c: 在函数‘x_cgo_sys_thread_create’中:
gcc_libinit_windows.c:57:12: 错误:implicit declaration of function ‘_beginthread’; did you mean ‘OpenThread’? [-Werror=implicit-function-declaration]
thandle = _beginthread(func, 0, arg);
^~~~~~~~~~~~
OpenThread
cc1:所有的警告都被当作是错误
go: failed to remove work dir: GetFileInformationByHandle D:\cygwin64new\tmp\go-build109746670\NUL: Incorrect function.
make: *** [Makefile:5:default] 错误 2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.