Skip to content

Instantly share code, notes, and snippets.

View kostix's full-sized avatar

Konstantin Khomoutov kostix

  • TradingView
  • Saint-Petersburg, Russia
View GitHub Profile
@kostix
kostix / hello.go
Last active August 19, 2018 18:20
A real test for cgo code https://github.com/dyu/ffi-overhead
package main
/*
#cgo CFLAGS: -Wall -O2 -fPIC
#cgo linux CFLAGS: -DLINUX=1
#cgo LDFLAGS: -Lnewplus -lnewplus -Wl,-rpath='$ORIGIN'/newplus
#include <stdlib.h>
#include "newplus/plus.h"
*/
import "C"
@kostix
kostix / ifspace.go
Created April 4, 2016 15:18
Getting Ethernet interface speed on Linux using Go via cgo
package main
/*
#include <stdio.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <netinet/in.h>
#include <linux/sockios.h>
#include <linux/if.h>
@kostix
kostix / netapi32.go
Created March 9, 2016 23:36
Wrapping Win32 API NetSessionEnum() in Go
package main
import (
"log"
"syscall"
"unicode/utf16"
"unsafe"
"time"
)
@kostix
kostix / tempfile\tempfile.go
Last active February 11, 2016 14:21
`tempfile` Go package mimicking mkstemp(3) and mkstemps(3) libc calls
package tmpfile
import (
"bytes"
"errors"
"os"
"sync/atomic"
"time"
)
@kostix
kostix / impersonate.go
Created September 30, 2014 16:46
A demonstration example for http://stackoverflow.com/a/26124494
// A demonstration example for http://stackoverflow.com/a/26124494
// It runs a goroutine locked to an OS thread on Windows
// then impersonates that thread as another user using its name
// and plaintext password, then reverts to the default security
// context before detaching from its OS thread.
package main
import (
"log"
"runtime"