原创 go流程控制2
if a > 20 { }else{ } witch mark{ case 10: default: } x.(type) select 會隨機選擇一個case,沒有case則default,無default將阻塞
原创 go面向對象4
1.匿名字段 2.接口 inrerface是一組method的集合 type writer interface(){ say() } 接口類型變量可以存儲(實現了該接口的實例) 值接口和指針接受有區分 空接口類型變量可以存儲任何
原创 go函數與方法3
func test (x,y int ,s string)(int,string){ return x,y } 值傳遞:值複製傳遞,不影響實際參數 引用傳遞:址的拷貝,實際參數地址傳遞,影響實際值 返回值:x,y/x,_:=test
原创 go基礎一
1.聲明:var、const、type、func 2.內置類型與函數: bool、string、array、complex64、complex128 int8、int16、int32、int64 uint8、ui
原创 go 包依賴管理
1.go mod (1.1+) go mod init go go mod tidy go mod vendor go list -m all 3.govendor(1.5+)
原创 redis緩存穿透、雪崩原因與解決方案
redis技術就是NoSQL技術中的一種,但是引入redis又有可能出現緩存穿透,緩存擊穿,緩存雪崩等問題。本文就對這三種問題進行較深入剖析 緩存穿透:key對應的數據在數據源並不存在,每次針對此key的請求從緩存獲取不到,請求都會到數據
原创 go常用標準庫6
ftm time Flag IO: inteface:Reader、Writer、ReaderFrom、ReaderAt 寫操作:Write、WriteString、WriteAt、WriteTi、Seek、Sync
原创 go併發編程5
1.goroutine 進程Process:操作系統中的執行過程、資源分配和調度的獨立單位 線程Thread:是進程執行的實體,是CPU調度和分配的基本單位 協程coroutine:獨立棧空間、共享堆空
原创 go數據操作6
1.mysql go get github.com/go-sql-driver/mysql go get github.com/jmoiron/sqlx type Person struct{ Userid int `db:use
原创 Composer原理
Composer作爲PHP的包管理工具,爲PHPer們提供了豐富的類庫 1.__autoload:嘗試加載未定義的類 2.spl_autoload_register:註冊給定的函數作爲 __autoload 的實現 spl_autoloa
原创 go.protobuf7
protoc下載:https://github.com/protocolbuffers/protobuf/releases protoc-gen-go:go get -u github.com/golang/protobuf/protoc
原创 go遠程調用grpc
1.rpc:本地方法調用與網絡通信技術 server: type MathUser struct { } type MathRequest struct { Min int Mix int } type MathRespo
原创 服務發現consul與etcd
1.consul 啓動節點:consul agent -dev -config-dir /etc/consul.d/ 查看節點:consul members UI界面:http://localhost:8500 服務查詢: dns方式:d
原创 Xss與Csrf
1.XSS:跨站腳本攻擊,Cross-Site Scripting,爲了和前端的css避免重名,簡稱爲XSS,是指通過技術手段,向正常用戶請求的HTML頁面中插入惡意腳本,執行。 主要就是通過對用戶輸入的數據做過濾或者是轉義,可以使用框架
原创 redis分佈式鎖之php
在單進程的系統中,當遇到併發情況下,會出現一些數據異常的問題,但是如果這些數據是需要保證唯一性的話,那我們就希望在同一時刻,只能有一個線程在執行這塊代碼,通常我們一般都是通過簡單的加鎖或同步來實現並解決這個問題。 但是以上都是單進程多線程