This project has moved to https://github.com/jonhoo/drwmutex so it can be imported into Go applications.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "log" | |
| "bufio" | |
| "time" | |
| "os" | |
| "fmt" | |
| "io" | |
| "net" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "./binding" | |
| "fmt" | |
| ) | |
| func main() { | |
| binding.PrintHello() | |
| binding.Seed(1) | |
| fmt.Println(binding.Random()) |
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| all: | |
| make build | |
| make objdump | |
| build: | |
| go build -gcflags -m main.go | |
| objdump: | |
| go tool objdump -s "main.main" main | grep CALL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MAKE := make --no-print-directory | |
| DESCRIBE := $(shell git describe --match "v*" --always --tags) | |
| DESCRIBE_PARTS := $(subst -, ,$(DESCRIBE)) | |
| VERSION_TAG := $(word 1,$(DESCRIBE_PARTS)) | |
| COMMITS_SINCE_TAG := $(word 2,$(DESCRIBE_PARTS)) | |
| VERSION := $(subst v,,$(VERSION_TAG)) | |
| VERSION_PARTS := $(subst ., ,$(VERSION)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- Refer to manual: https://knot-resolver.readthedocs.io/en/latest/daemon.html#configuration | |
| -- Listen on all interfaces (localhost would not work in Docker) | |
| net.listen('0.0.0.0') | |
| net.listen('0.0.0.0', 853, {tls=true}) | |
| -- Auto-maintain root TA | |
| trust_anchors.file = '/data/root.keys' | |
| -- Load Useful modules |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package test | |
| import ( | |
| "bytes" | |
| "encoding/json" | |
| "testing" | |
| "github.com/golang/protobuf/jsonpb" | |
| structpb "github.com/golang/protobuf/ptypes/struct" | |
| "github.com/google/cel-go/cel" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Polar basics demo for the | |
| // FastLED Podcast #2 | |
| // https://www.youtube.com/watch?v=KKjFRZFBUrQ | |
| // | |
| // VO.1 preview version | |
| // by Stefan Petrick 2023 | |
| // This code is licenced under a | |
| // Creative Commons Attribution | |
| // License CC BY-NC 3.0 |
OlderNewer