关闭

Go1.9获取rsa证书的指纹码

package mainimport ( "crypto/sha1" "encoding/hex" "fmt" "github.com/czxichen/work-stacks/tools/encrypt" )const c = `-----BEGIN CERTIFICATE----- MIICeTCCAiOgAwIBAgIICqroUds7aqYwDQYJKoZIhv...
阅读(39) 评论(0)

Go1.9不使用http2提高http传输效率

内部应用对外提供httpAPI,QPS提不上去,于是对接口进行了改造,将短链接改成长连接,在长连接上做数据交互.QPS有了显著提高,代码片段.内部实现是自定义解析http的,类似于fasthttp的方法,需要时解析,这里是用标准库的方法做的小实例package mainimport ( "bufio" "io" "log" "net" "net/http"...
阅读(108) 评论(0)

Go1.9组播发送消息小实例

package mainimport ( "flag" "fmt" "net" "syscall" )var ( ttl int daemon bool port = 12389 multiaddr = [4]byte{224, 0, 1, 1} inaddr_any = [4]byte{0,...
阅读(172) 评论(0)

Go1.9基于http备份文件中心服务器

package mainimport ( "archive/zip" "crypto/md5" "encoding/hex" "encoding/json" "flag" "io" "io/ioutil" "log" "net" "net/http" "net/url" "os" "path/fi...
阅读(161) 评论(0)

Go1.9获取Windows进程专用内存工作集

package main/* #include #include void CountPrivate(PSAPI_WORKING_SET_INFORMATION* workSetInfo,int* count) { int workSetPrivate = 0; for (ULONG_PTR i = 0; i N...
阅读(270) 评论(0)

Go1.9windows创建服务小实例

package mainimport ( "context" "fmt" "log" "net" "net/http" "os" "github.com/kardianos/service" )type services struct { log service.Logger srv *http.Server cfg *s...
阅读(412) 评论(0)

Go1.9按行读取日志文件并处理

package mainimport ( "bufio" "bytes" "context" "log" "os" "sync" )const ( logname = "log" concurrent = 5 //并发处理数,可以根据物理内存调整 maxsize = 10 * 1024...
阅读(430) 评论(0)

Go1.9 tcpproxy代理小实现

package mainimport ( "io" "log" "net" "strings" "sync" "time" )func main() {}type remote struct { mu sync.Mutex addr string inactive bool }func (r *remote)...
阅读(275) 评论(0)

Golang1.8编译静态库给C使用

Go实例代码:package mainimport ( "fmt" )import "C"//export Printf func Printf(format, str string) { fmt.Printf(format, str) }func main(){} 编译命令: go build -ldflags “-s -w” -buildmode=c-archive -o pr...
阅读(798) 评论(0)

Go1.8实现watchdog功能,实现依赖启动服务程序

package mainimport ( "flag" "fmt" "io" "os" "os/signal" "os/user" "path" "strconv" "strings" "sync" "syscall" "time" "github.com/czxichen/command/watc...
阅读(625) 评论(0)

golang1.8使用cgo获取进程是否假死

package mainimport ( "flag" )/* #include #include #include typedef struct EnumFunArg { HWND hWND; DWORD dwProcessId; }EnumFunArg,*LPEnumFunArg;BOOL...
阅读(378) 评论(0)

Go1.8抓取网络数据包

package main//+build linuximport ( "fmt" "github.com/google/gopacket" "github.com/google/gopacket/pcap" )func main() { // 指定监听的网络为eth0,每次捕获消息大小,是否已混合模式打开, if handle, err := pcap.Open...
阅读(549) 评论(0)

Go1.8从文件结尾读取文件

package mainimport ( "bytes" "io" "os" "sync" )func main() { File, err := os.OpenFile("main.go", os.O_RDONLY, 0644) if err != nil { println(err.Error()) return...
阅读(205) 评论(0)

Golang1.8获取Windows硬件信息小实例.

package mainimport ( "fmt" "net" "runtime" "strings" "syscall" "time" "unsafe" "github.com/StackExchange/wmi" )var ( advapi = syscall.NewLazyDLL("Advapi32.dll") k...
阅读(1019) 评论(0)

Go1.8操作Windows硬盘小实例

package main// #include import "C"import ( "bytes" "errors" "os" "syscall" "unsafe" )var ( success = "The operation completed successfully." kernel...
阅读(347) 评论(0)
160条 共11页1 2 3 4 5 ... 下一页 尾页
    个人资料
    • 访问:175133次
    • 积分:3362
    • 等级:
    • 排名:第10461名
    • 原创:157篇
    • 转载:2篇
    • 译文:1篇
    • 评论:33条
    文章分类
    最新评论