自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

JieLinDee的专栏

天道酬勤,厚积薄发.对Go语言有兴趣的朋友可以加:259693140(已满),858980110(02群),进群不允许

  • 博客(173)
  • 收藏
  • 关注

原创 验证码图片二值化去噪

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

2021-11-10 13:58:10 741

原创 Go1.10发送阿里dysms

package senderimport ( "crypto/hmac" "crypto/sha1" "encoding/base64" "encoding/json" "errors" "fmt" "io/ioutil" "net/http" "net/url&q

2018-07-03 12:58:35 784

原创 Go1.10帮他人写一个简单的CGO使用IcmpSendEcho的例子

package mainimport ( "fmt" "syscall" "unsafe")/*#include <winsock2.h>#include <iphlpapi.h>#include

2018-06-08 13:04:18 923

原创 Go1.10域名证书检查服务代码片段

package mainimport ( "context" "encoding/json" "flag" "fmt" "html/template" "io/ioutil&

2018-06-03 19:14:45 761

原创 Go1.10获取进程打开的动态库

type ListMode uintptrconst ( LIST_MODULES_DEFAULT ListMode = 0x0 //查看默认的模块 LIST_MODULES_32BIT = 0x01 //查看32-bit的模块 LIST_MODULES_64BIT = 0x02 //查看64-bit的模块 LIST...

2018-03-29 14:27:11 923

原创 Go1.10用Go函数控制C函数的生命周期

package mainimport ( "context" "syscall" "time" "unsafe")/*int goexit(void* func){ ((int (*)())func)(); return 0;}*/import "C"func main() { go func() { ...

2018-03-20 16:48:28 418

原创 Go1.10通过http创建任务计划

package mainimport ( "encoding/json" "flag" "fmt" "io/ioutil" "log" "net/http" "net/smtp" "net/url" "os" "os/exec"

2018-02-26 11:39:36 391

原创 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

2018-01-27 17:25:50 356

原创 Go1.10使用Windows系统API查看网络链接情况

package mainimport ( "fmt" "syscall" "unsafe")const ERROR_INSUFFICIENT_BUFFER = 122func main() { lazydll := syscall.NewLazyDLL("Iphlpapi.dll") proc := lazydll.NewProc("GetTc

2018-01-23 17:21:28 1879

原创 Go1.10在编译成dll小实例

package mainimport ( "net")//必须导入import "C"//编译成动态库也是必须的func main() {}//export Interfacesfunc Interfaces(list []string, retlen *int) string { interf, err := net.InterfaceAddrs() if err

2017-12-08 18:56:32 6527 1

原创 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

2017-12-06 17:34:44 5364

原创 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)}

2017-11-28 14:57:31 3504

原创 Go开发环境设置,包含第三方包下载使用技巧

一、安装Go环境:①下载地址: 官方下载 国内社区下载②下载好对应的版本后,解压放入自己需要的路径这里我放在根目录下. linux: 环境变量设置: 一般放入:(/etc/profile)中 export GOBIN=/go/bin 声明Go可执行文件路径 export GOROOT=/go 声明Go根目录路径 export GOP

2017-11-26 11:45:52 10495

原创 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

2017-10-27 17:10:48 975

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

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

2017-10-18 17:17:11 1224

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

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

2017-09-30 13:07:29 1715

原创 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,

2017-08-20 16:35:41 5366 2

原创 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

2017-08-10 11:31:11 572

原创 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

2017-07-23 12:43:08 1961

原创 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

2017-07-05 16:38:15 4059

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

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

2017-06-22 17:24:45 2841

原创 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)

2017-06-22 11:50:18 1464

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

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

2017-05-23 10:19:36 4242

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

package mainimport ( "flag" "fmt" "io" "os" "os/signal" "os/user" "path" "strconv" "strings" "sync" "syscall" "time" "github.com/czxichen/command/watc

2017-05-16 17:41:02 2739

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

package mainimport ( "flag")/*#include <stdio.h>#include <windows.h>#include <Winuser.h>typedef struct EnumFunArg{ HWND hWND; DWORD dwProcessId;}EnumFunArg,*LPEnumFunArg;BOOL

2017-05-12 17:44:43 1858

原创 Go1.8抓取网络数据包

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

2017-05-10 13:34:13 2970

原创 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

2017-05-03 18:31:06 3703

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

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

2017-04-18 17:05:18 9638 1

原创 Go1.8操作Windows硬盘小实例

package main// #include <stdlib.h>import "C"import ( "bytes" "errors" "os" "syscall" "unsafe")var ( success = "The operation completed successfully." kernel

2017-03-13 09:58:20 669

原创 Golang1.8标准库http.Fileserver跟http.ServerFile小例子

package mainimport ( "fmt" "net/http" "os" "path" "strings")var staticfs = http.FileServer(http.Dir("D:\\code\\20160902\\src\\"))func main() { //浏览器打开的时候显示的就是D:\\code\\20160902

2017-03-06 09:33:18 6206 2

原创 Golang1.8使用slice实现先进进出功能

package cacheimport ( "fmt")type lists struct { count int pop int last int index int list []int}func (l *lists) Add(i int) { l.list[l.last] = i l.last += 1 if

2017-03-03 16:02:59 2180

原创 Golang1.7.4标准库sql使用

package mainimport ( "database/sql" "errors" "fmt" "net" "sync/atomic" "time" "github.com/go-sql-driver/mysql")func main() {}//新建mysql连接,connstr为mysql连接串"root:123456@tcp(172

2017-02-04 17:46:15 852

原创 Go1.7.3一个收发消息的小接口

package transportimport ( "encoding/binary" "errors" "io" "math" "sync")const ( sizeLen = 5 //设置消息多少字节大小,1<<4*8-1长度,最后一个字节用来做消息分割的,防止恶意链接)var ( ErrLength = errors.New("mes

2017-01-09 17:09:48 622

原创 分享一个运维过程中的用的命令集合

[代码有点多放在git上面了](https://github.com/czxichen/wstools)Install: go install -ldflags "-s -w" github.com/czxichen/wstoolsWstools Usage: wstools [arguments]The commands are: fileserver 用过http

2017-01-09 16:59:33 661

原创 Go1.7.3简单的ftp协议交互

package mainimport ( "bufio" "bytes" "errors" "fmt" "io" "log" "net" "os" "strconv" "strings")func main() { f, err := NewFtp("172.18.80.247:300", "test", "1

2016-12-16 11:11:43 1001 3

原创 Go1.7.3运维文件夹比较工具,可以支持远程比较

package mainimport ( "bufio" "bytes" "crypto/md5" "encoding/hex" "errors" "flag" "fmt" "hash" "io" "log" "net/http" "os" "path/filepath" "strings

2016-12-14 10:46:01 1381

原创 Golang1.7.3简单的rsa加密封装

package rsasimport ( "bytes" "crypto/rand" "crypto/rsa" "crypto/x509" "crypto/x509/pkix" "encoding/pem" "errors" "io" "io/ioutil" "math/big" rd "math/rand"

2016-12-12 11:55:37 1014

原创 Golang1.7.3发送大附件邮件

package mainimport ( "bytes" "crypto/tls" "encoding/base64" "errors" "fmt" "io" "mime" "mime/multipart" "mime/quotedprintable" "net/smtp" "net/textproto"

2016-12-01 15:20:05 2059

原创 Golang1.7.3实现启动单一实例代码片段

var ( NameMutex = "Shamem" kernel = syscall.NewLazyDLL("kernel32.dll"))const ( IPC_RMID = 0 IPC_CREAT = 00001000 IPC_EXCL = 00002000 IPC_NOWAIT = 00004000)func Lock_wi

2016-11-25 18:12:39 1088

原创 Golang1.7.3使用标准库的AES加密解密不实用扩展协议

package mainimport ( "crypto/aes" "crypto/cipher" "fmt")type tobytes struct { cip cipher.Block pdgtext []byte}func main() { cip, _ := aes.NewCipher([]byte("123456789123456

2016-11-22 10:44:12 1653

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除