Skip to content

Instantly share code, notes, and snippets.

```
// 函数
// 判断在 b(s、r)中能否找到 pattern 所匹配的字符串
func Match(pattern string, b []byte) (matched bool, err error)
func MatchString(pattern string, s string) (matched bool, err error)
func MatchReader(pattern string, r io.RuneReader) (matched bool, err error)
// 将 s 中的正则表达式元字符转义成普通字符。
func QuoteMeta(s string) string
package main
import (
"errors"
"fmt"
)
// Rule struct
type Rule struct {
match func(x, y int) bool
@islishude
islishude / ssl-shakehand.md
Created October 30, 2017 01:45
HTTPS加密协议详解:TLS/SSL握手过程

握手与密钥协商过程

基于RSA握手和密钥交换的客户端验证服务器为示例详解TLS/SSL握手过程。

client_hello

客户端发起请求,以明文传输请求信息,包含版本信息,加密套件候选列表,压缩算法候选列表,随机数,扩展字段等信息,相关信息如下:

支持的最高TSL协议版本version,从低到高依次 SSLv2 SSLv3 TLSv1 TLSv1.1 TLSv1.2,当前基本不再使用低于 TLSv1 的版本;

@islishude
islishude / go-slice.go
Created August 11, 2018 01:45
Golang `slice` isn't point instead of a struct
package main
import "fmt"
func main() {
test := []int{0, 1, 2}
fmt.Printf("最初的内存地址是 %p 值为:%v \n", test, test)
change(test)
fmt.Printf("出函数的内存地址是 %p 值为:%v \n", test, test)
}
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
)
func main() {
@islishude
islishude / go-pipeline
Created October 17, 2018 11:52
goroutine with pipeline
package main
import (
"fmt"
)
func main() {
data := []int{1, 2, 3, 4}
// data |> time |> plus
ret := plus(time(data))
@islishude
islishude / chan.go
Created December 5, 2018 13:23
Go: 使用 Channel 处理多值返回
package main
import (
"log"
"time"
)
func main() {
log.Println("start")
num, err := func() (int, error) {
@islishude
islishude / ubuntu-1804-aliyun-apt
Created January 22, 2019 13:53
u1804-aliyun.sourelist
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
@islishude
islishude / aliyun-apt-1604.txt
Created January 23, 2019 08:33
ubuntu1606-aliyun-apt
#aliyun
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse