验证码图片二值化去噪 package mainimport ( "image" "gocv.io/x/gocv")func main() { mat := gocv.IMRead("2.png", gocv.IMReadColor) defer mat.Close() bilatera := gocv.NewMat() defer bilatera.Close() gocv.BilateralFilter(mat, &bilatera, 0, 100, 15) gocv.MedianBlu
Go1.10发送阿里dysms package senderimport ( "crypto/hmac" "crypto/sha1" "encoding/base64" "encoding/json" "errors" "fmt" "io/ioutil" "net/http" "net/url&q
Go1.10帮他人写一个简单的CGO使用IcmpSendEcho的例子 package mainimport ( "fmt" "syscall" "unsafe")/*#include <winsock2.h>#include <iphlpapi.h>#include
Go1.10域名证书检查服务代码片段 package mainimport ( "context" "encoding/json" "flag" "fmt" "html/template" "io/ioutil&
Go1.10获取进程打开的动态库 type ListMode uintptrconst ( LIST_MODULES_DEFAULT ListMode = 0x0 //查看默认的模块 LIST_MODULES_32BIT = 0x01 //查看32-bit的模块 LIST_MODULES_64BIT = 0x02 //查看64-bit的模块 LIST...
Go1.10用Go函数控制C函数的生命周期 package mainimport ( "context" "syscall" "time" "unsafe")/*int goexit(void* func){ ((int (*)())func)(); return 0;}*/import "C"func main() { go func() { ...
Go1.10通过http创建任务计划 package mainimport ( "encoding/json" "flag" "fmt" "io/ioutil" "log" "net/http" "net/smtp" "net/url" "os" "os/exec"
Go1.10求给定范围内的素数 package mainimport ( "fmt")//素数定义:1除外只能被他本身和1整除的数字func main() { var list []int for i := 2; i 100; i++ { if i/2 == 0 { continue } if !check(list, i
Go1.10使用Windows系统API查看网络链接情况 package mainimport ( "fmt" "syscall" "unsafe")const ERROR_INSUFFICIENT_BUFFER = 122func main() { lazydll := syscall.NewLazyDLL("Iphlpapi.dll") proc := lazydll.NewProc("GetTc
Go1.10在编译成dll小实例 package mainimport ( "net")//必须导入import "C"//编译成动态库也是必须的func main() {}//export Interfacesfunc Interfaces(list []string, retlen *int) string { interf, err := net.InterfaceAddrs() if err
Go1.9接入prometheus监控小实例 package mainimport ( "bytes" "fmt" "net/http" "strings" "sync/atomic" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/common/expfmt")type statusColle
Go1.9安全的限制net.Listener接入连接数 package mainimport ( "fmt" "net" "sync" "sync/atomic")func main() { lis, err := net.Listen("tcp", ":1789") if err != nil { return } lis = LimitListener(lis, 1)}
Go开发环境设置,包含第三方包下载使用技巧 一、安装Go环境:①下载地址: 官方下载 国内社区下载②下载好对应的版本后,解压放入自己需要的路径这里我放在根目录下. linux: 环境变量设置: 一般放入:(/etc/profile)中 export GOBIN=/go/bin 声明Go可执行文件路径 export GOROOT=/go 声明Go根目录路径 export GOP
Go1.9帮同事写个备份上传小程序,带推告警到open-falcon功能 package mainimport ( "archive/zip" "encoding/json" "flag" "io/ioutil" "log" "net/http" "os" "strings" "time" "github.com/jlaffaye/ftp")type Config struct { E
Go1.9获取rsa证书的指纹码 package mainimport ( "crypto/sha1" "encoding/hex" "fmt" "github.com/czxichen/work-stacks/tools/encrypt")const c = `-----BEGIN CERTIFICATE-----MIICeTCCAiOgAwIBAgIICqroUds7aqYwDQYJKoZIhv
Go1.9不使用http2提高http传输效率 内部应用对外提供httpAPI,QPS提不上去,于是对接口进行了改造,将短链接改成长连接,在长连接上做数据交互.QPS有了显著提高,代码片段.内部实现是自定义解析http的,类似于fasthttp的方法,需要时解析,这里是用标准库的方法做的小实例package mainimport ( "bufio" "io" "log" "net" "net/http"
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,
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
Go1.9获取Windows进程专用内存工作集 package main/*#include <windows.h>#include <Psapi.h>void CountPrivate(PSAPI_WORKING_SET_INFORMATION* workSetInfo,int* count){ int workSetPrivate = 0; for (ULONG_PTR i = 0; i < workSetInfo->N
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