cgo

Posted by 夏泽民

https://github.com/golang/go/wiki/cgo



ast rewrite

Posted by 夏泽民

https://github.com/fatih/astrewrite http://goast.yuroyoro.net/ https://github.com/xdg-go/go-rewrap-errors At work, my team decided to switch our codebase from pkg/errors to Go 1.13’s native error wrapping. We used to wrap our errors like this:



Pkg-Config cgo

Posted by 夏泽民

https://github.com/xlab/c-for-go



Deadline

Posted by 夏泽民

package main



CFLAGS

Posted by 夏泽民

https://github.com/chai2010/advanced-go-programming-book/blob/master/ch2-cgo/ch2-02-basic.md 要使用CGO特性,需要安装C/C++构建工具链,在macOS和Linux下是要安装GCC,在windows下是需要安装MinGW工具。同时需要保证环境变量CGO_ENABLED被设置为1,这表示CGO是被启用的状态。在本地构建时CGO_ENABLED默认是启用的,当交叉构建时CGO默认是禁止的。比如要交叉构建ARM环境运行的Go程序,需要手工设置好C/C++交叉构建的工具链,同时开启CGO_ENABLED环境变量。然后通过import “C”语句启用CGO特性。 2.2.1 import “C”语句 如果在Go代码中出现了import “C”语句则表示使用了CGO特性,紧跟在这行语句前面的注释是一种特殊语法,里面包含的是正常的C语言代码。当确保CGO启用的情况下,还可以在当前目录中包含C/C++对应的源文件。



Search

Popular posts

Anything in here will be replaced on browsers that support the canvas element

Recent posts

This blog is maintained by 夏泽民

Get in touch with me at 465474307@qq.com

Subscribe to our mailing list

* indicates required