https://github.com/go-vgo/Mingw
https://github.com/gin-gonic/gin/blob/master/examples/assets-in-binary/README.md
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://marketplace.visualstudio.com/items?itemName=humao.rest-client
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)
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