Skip to content

Instantly share code, notes, and snippets.

View akamensky's full-sized avatar
💻
coding for fun

Alexey Kamenskiy akamensky

💻
coding for fun
View GitHub Profile
@akamensky
akamensky / README.md
Last active March 27, 2018 18:01
Passing arrays of structs between Go and C
  1. Put cinterface.go, cinterface.c and test.h in ~/go/src/cinterface/
  2. Then call go build -buildmode=c-archive cinterface, this will produce cinterface.a and cinterface.h in current directory
  3. Put main.c and test.h in current directory and call gcc -o main -I. cinterface.a main.c, this will produce final binary
@akamensky
akamensky / example.go
Created March 9, 2018 11:13
Easy golang process daemon
package main
import (
"os/exec"
"os"
"time"
)
func init() {
isForked := os.Getenv("DAEMON")

This is an example. To run it simply do go build -o slave slave.go && go build -o main main.go && ./main Then you can try typing say for slave process to produce output or exit for slave process to exit. There is an issue when slave exits main process still alive and starts burning through CPU cycles.

But I am lazy to fix that, feel free to do that.

@akamensky
akamensky / RouteMatchingTest
Last active August 29, 2015 14:05
failing test
/*
* Copyright 2014 - Alexey Kamenskiy
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software