[轉]nodejs vs golang Web3 Performance comparison
https://docs.etherniti.org/architecture/benchmarks/performance_test/
https://docs.etherniti.org/architecture/benchmarks/performance_test/
https://docs.etherniti.org/architecture/optimizations/address-validation/ package main import ( "fmt" "regexp" ) var ( re := regexp.MustCompile("^0x[0-9a-fA-F]{40}$") ) func IsValidAddress(v string) bool { return re.MatchString(v) } func main() { fmt.Println(IsValidAddress("0x323b5d4c32345ced77393b3530b1eed0f346429d")) // true fmt.Println(IsValidAddress("0xXYZb5d4c32345ced77393b3530b1eed0f346429d")) // false }
https://pliutau.com/go-modules-docker/
https://christina04.hatenablog.com/entry/vault-login-golang user passwd get token https://www.vaultproject.io/docs/auth/userpass.html setting token https://www.vaultproject.io/docs/auth/token.html
https://yami.io/golang-interface/
https://www.reddit.com/r/golang/comments/8ojjoj/huge_performance_hit_on_a_simple_go_server_with/ Docker’s disk I/O was the bottleneck! Solved: Disk I/O was the problem. Even though I’m on Debian 9.4, changing to an in-memory sqlite allowed Docker to push 2.9k reqs/sec. Credits to /u/Willson50 for the amazing find! With file=dco.sqlite3?mode=memory, Docker can push ~2.9k req/sec. Other way: PRAGMA journal_mode=WAL; PRAGMA synchronous=NORMAL; https://www.sqlite.org/wal.html
https://github.com/karalabe/xgo
https://zhuanlan.zhihu.com/p/48039838
.bashrc last line: export PATH="/usr/local/go/bin:$PATH"
1、Authenticator old:Authenticator: func(userId string, password string, c *gin.Context) New: ============================ `` type login struct { Username string `form:"username" json:"username" binding:"required"` Password string `form:"password" json:"password" binding:"required"` } Authenticator: func(c *gin.Context) (interface{}, error) { var loginVals login if err := c.ShouldBind(&loginVals); err != nil { return "", jwt.ErrMissingLoginValues } userID := loginVals.Username password := loginVals.Password `` 2、authMiddleware old: authMiddleware := jwt.GinJWTMiddleware{ New: authMiddleware, err := jwt.New(&jwt.GinJWTMiddleware{
https://segmentfault.com/a/1190000016179093
telegram Gopher 台灣 @winampmaker https://play.golang.org/p/RObzlfjZSRi ` func struct2Map(model interface{}, tagName string) map[string]interface{} { m := make(map[string]interface{}) r := reflect.ValueOf(model) total := r.NumField() for i := 0; i < total; i++ { m[r.Type().Field(i).Tag.Get(tagName)] = r.Field(i).Interface() } return m } ` ============================ ` "github.com/fatih/structs" func StructtoMapbyTag(tr interface{}, tag string) map[string]interface{} { t := make(map[string]interface{}) //儲存處理過的m s := structs.New(tr) m := s.Map() //先轉成map[string]interface{} for key, value := range m { t[s.Field(key).Tag(tag)] = value.(string) } return t } `
Usually how to tech is ` req, err := http.NewRequest("GET", "http://example.com", nil) req.Header.Add("Authorize", "dswxswsxw") resp, err := client.Do(req) ` BUT Have problem inside. So…. use this ` headers := http.Header{ "Accept-Encoding": []string{"gzip, deflate"}, } req, err := http.NewRequest("GET", url, nil) req.Header = headers client := &http.Client{} resp, err = client.Do(req) ` More Safe.
https://segmentfault.com/a/1190000015323550
GraphQL https://www.thepolyglotdeveloper.com/2018/05/getting-started-graphql-golang/ https://www.thepolyglotdeveloper.com/2018/05/maintain-data-relationships-resolvers-graphql-golang-application/ https://www.thepolyglotdeveloper.com/2018/07/jwt-authorization-graphql-api-using-golang/
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 { claims := jwt.ExtractClaims(c) id := claims[“aaaaaaa”].(string) ...
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.go CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go ...