gorgonia.org/gorgonia@v0.9.17/DEVNOTES.md (about) 1 # Cgo # 2 3 Cgo is used pretty heavily in Gorgonia. Here are some Cgo guidelines that I've come up with and used over the years: 4 5 1. Use astyle to fmt your C code. This is the command to use: `astyle --style=google -lineend=linux --indent=tab --indent-switches --align-pointer=type --align-reference=name --delete-empty-lines`. Yes, the choices are a bit weird, but it makes C more like Go code, which is readable af. 6 2. When passing Go slices to a C function, pass a splatted [fat pointer](http://www.drdobbs.com/architecture-and-design/cs-biggest-mistake/228701625). What I mean by this is to do something like this (cap is optional but recommended): 7 8 ```c 9 void foo(double* sliceF64, int len, int cap) { 10 11 } 12 ``` 13 3. Brackets are your friends. It's tempting to write this: 14 ```c 15 if (foo) 16 bar() 17 ```. 18 Don't. Write shis instead: 19 ```c 20 if (foo) { 21 bar() 22 } 23 ``` 24 25 #Go Assembly# 26 27 When writing Go Assembly, use [asmfmt](https://github.com/klauspost/asmfmt)