Batch size = 400
Keys are sorted.
See the results below.
Batch size = 400
Keys are sorted.
See the results below.
At Vimeo, on the transcoding team, we work a lot with Go, and a lot with C, for various tasks such as media ingest. This means we use CGO quite extensively, and consequently, have run into bits that are perhaps not very well documented, if at all. Below is my effort to document some of the problems we've run into, and how we fixed or worked around them.
Many of these are obviously wrong in retrospect, but hindsight is 20/20, and these problems do exist in many codebases currently.
Some are definitely ugly, and I much welcome better solutions! Tweet me at @daemon404 if you have any, or have your own CGO story/tips, please! I'd love to learn of them.
Table of Contents
import "time" | |
type Session struct { | |
ID string | |
CreatedAt time.Time | |
} | |
type SessionPool struct { | |
size int | |
ttl time.Duration |
var nodeParentPairs = []; | |
var sourceXML; | |
function prepareWebKitXMLViewer(noStyleMessage) | |
{ | |
var html = createHTMLElement('html'); | |
var head = createHTMLElement('head'); | |
html.appendChild(head); | |
var style = createHTMLElement('style'); | |
style.id = 'xml-viewer-style'; | |
head.appendChild(style); |
func split(buf []byte, lim int) [][]byte { | |
var chunk []byte | |
chunks := make([][]byte, 0, len(buf)/lim+1) | |
for len(buf) >= lim { | |
chunk, buf = buf[:lim], buf[lim:] | |
chunks = append(chunks, chunk) | |
} | |
if len(buf) > 0 { | |
chunks = append(chunks, buf[:len(buf)]) | |
} |
Говорил Керниган Пайку: Ты погодь язык свой писать, покамест три книжки со мной в соавторстве не напишешь! | |
Написал Роб Пайк один язык с каналами, отнес его Кернигану, а тот лишь в бороду ухмыляется | |
Рассстроился молодой Роб, но виду не подал. | |
Пошел писать терминал графический и вышел он у него краше некуда. Да только к тому времени люди про терминалы уже и думать забыли (edited) | |
Тогда решил уже повзрослевший Пайк второй язык написать, да не просто написать а в наикрутейшем редакторе | |
А так как такого не было, написал свой | |
А потом написал в нем второй свой язык. | |
И пошел гордый собой свой язык, написанный в новом супер редакторе Кернигану показывать | |
А тот как увидел – стал языком цокать, да только не на язык глядючи, а на редактор. | |
Хорош у тебя редактор вышел, говорит. Молодец! |
package main | |
import ( | |
"./binding" | |
"fmt" | |
) | |
func main() { | |
binding.PrintHello() | |
binding.Seed(1) | |
fmt.Println(binding.Random()) |
char a1; // type of a1 is C.char | |
char *a2; // type of a2 is *C.char | |
char a3[1]; // type of a3 is [1]C.char | |
char a4[1][2]; // type of a4 is [1][2]C.char | |
char a5[1][2][3]; // type of a5 is [1][2][3]C.char | |
char *a6[1][2][3]; // type of a6 is [1][2][3]*C.char | |
char **a7[1][2][3]; // type of a7 is [1][2][3]**C.char | |
char ***a8[1][2]; // type of a8 is [1][2]***C.char | |
char *a9[1][2]; // type of a9 is [1][2]*C.char | |
char **a10[1]; // type of a0 is [1]**C.char |
localhost(~/src) % gccgo -v | |
Using built-in specs. | |
COLLECT_GCC=gccgo | |
COLLECT_LTO_WRAPPER=/opt/libexec/gcc/arm-linux-gnueabihf/4.8.2/lto-wrapper | |
Target: arm-linux-gnueabihf | |
Configured with: ../gccgo/configure --prefix=/opt --enable-languages=c,c++,go --with-ld=/usr/bin/ld --enable-shared --without-included-gettext --enable-threads=posix --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libitm --with-system-zlib --with-cloog --enable-cloog-backend=ppl --disable-cloog-version-check --disable-ppl-version-check --enable-multiarch --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb --disable-werror --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf | |
Thread model: posix | |
gcc version 4.8.2 20130927 (prerelease) (GCC) | |
localhost(~/src) % go run -compiler gccgo helloworld.go | |
Hello gccgo |
#pragma once | |
enum Options { | |
One, Two, Three | |
}; | |
const char *hello = "hello world!"; | |