Skip to content

Instantly share code, notes, and snippets.

Avatar
🙃

skoo skoo87

🙃
View GitHub Profile
View unsafe2_setopt.go
package main
import (
"net"
"unsafe"
"syscall"
)
func main() {
conn, err := net.Dial("tcp", "www.taobao.com:80")
View unsafe1_setopt.go
package main
import (
"net"
"unsafe"
"syscall"
)
type fdMutex struct {
state uint64
View alloc_large_mem.go
package main
import (
"reflect"
"unsafe"
)
type TestStruct struct {
A int
B string
@skoo87
skoo87 / go-epoll-server
Last active Sep 16, 2017
这是一个用 Go 基于 epoll 写的服务器程序,虽然 epoll 的实现不是很完善,还有许多细节需要改善,但此程序可以作为 Go epoll 开发的样例。这个程序也是在一个特定的需求场景下写的。
View go-epoll-server
package main
import (
"bytes"
"encoding/binary"
"flag"
"io"
"log"
"os"
"runtime"
@skoo87
skoo87 / go-get-gitlab.patch
Created Sep 15, 2014
go get支持gitlab的patch
View go-get-gitlab.patch
--- go/src/cmd/go/vcs.go 2014-08-13 11:49:45.000000000 +0800
+++ /Users/marckywu/local/go/src/cmd/go/vcs.go 2014-09-15 12:41:43.000000000 +0800
@@ -587,6 +587,24 @@
check: oldGoogleCode,
},
+ // Gitlab
+ {
+ prefix: "gitlab.test.com/",
+ re: `^(?P<root>gitlab\.test\.com/[A-Za-z0-9_.\-]+/[A-Za-z0-9_.\-]+)(/[A-Za-z0-9_.\-]+)*$`,
@skoo87
skoo87 / varint.c
Created Sep 30, 2013
base 128 varint编码解码算法
View varint.c
#include <stdio.h>
#include <stdint.h>
int encode_varint(char *buf, uint64_t x)
{
int n;
n = 0;
while (x > 127) {
View test_channel.go
package main
import (
"runtime"
"time"
)
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
@skoo87
skoo87 / go_shuffle.go
Created Sep 27, 2013
go runtime中的洗牌算法测试
View go_shuffle.go
package main
import (
"math/rand"
"time"
"fmt"
)
var report map[int][]int
@skoo87
skoo87 / detect-utf8.go
Last active Dec 22, 2015
判断一段数据是否是utf-8编码
View detect-utf8.go
const (
UTF_BYTE_MASK1 = 0xF0
UTF_BYTE_MASK2 = 0xC0
UTF_BYTE_MASK3 = 0xC0
UTF_BYTE_VALUE1 = 0xE0
UTF_BYTE_VALUE2 = 0x80
UTF_BYTE_VALUE3 = 0x80
)
@skoo87
skoo87 / go-rpc-bm-client.go
Last active Sep 22, 2021
go rpc benchmark
View go-rpc-bm-client.go
package main
import (
"flag"
"fmt"
"log"
"net/rpc"
"sync"
"time"
)