gin-jwt

1. Authenticator 回傳的 data 2. data 會丟入到 PayloadFunc 3. PayloadFunc 整理資料寫入 MapClaims 4. Authorizator 再拿 MapClaims 資料出來判斷 新版和舊版有地方不同 type xxxxx struct{  aaaaaaa:string } 1、 Authenticator: func(userId string, password string, c *gin.Context) (interface{}, bool) { return xxxxx{aaaaaaa: ooooxxxx} or string 2、 PayloadFunc: func(data interface{}) jwt.MapClaims { if v, ok := data.(xxxxx); ok { id = data.(xxxxx).aaaaaaa } return jwt.MapClaims{“aaaaaaa”: ooooxxxx, “bbbbbbb”: ooooxxxx} 3、 Authorizator: func(data interface{}, c *gin.Context) bool {

繼續閱讀

https://www.jisec.com/application-development/753.html OS ARCH OS version linux 386 / amd64 / arm >= Linux 2.6 darwin 386 / amd64 OS X (Snow Leopard + Lion) freebsd 386 / amd64 >= FreeBSD 7 windows 386 / amd64 >= Windows 2000  go env Mac 下编译 Linux 和 Windows 64位可执行程序 CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.go CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go Linux 下编译 Mac 和 Windows 64位可执行程序 CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build main.

繼續閱讀

Golang often us []interface{} or map[string]interface{} sqlx.Queryx Alternate Scan Types rows, err := db.Queryx(“SELECT * FROM place”) for rows.Next() { // cols is an []interface{} of all of the column results cols, err := rows.SliceScan() } rows, err := db.Queryx(“SELECT * FROM place”) for rows.Next() { results := make(map[string]interface{}) err = rows.MapScan(results) } So func Sqlselectall(db1 *sqlx.DB, table string) []map[string]interface{} {  rows, err := db1.Queryx(“SELECT * FROM " + table)

繼續閱讀

windows docker go

1、go mkdir directory aaa create file go_httpserver.go package main import ( “fmt” “net/http” ) func handler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, “Welcome to my Website!!!\n %s”, r.URL.Path[1:]) } func main() { http.HandleFunc("/", handler) http.ListenAndServe(“0.0.0.0:80”, nil) } set GOARCH=amd64 set GOOS=linux go build go_httpserver.go => get linux go program 2、create docker image 2.1 install docker toolbox Link 2.2 run kitematic then see left-down DOCKER CLI , click it, then 2.2.1 create directory bbb

繼續閱讀

作者的圖片

Sue boy

Sueboy Can support You

CIO

Taiwan