This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package common | |
import ( | |
"fmt" | |
"net" | |
"net/http" | |
_ "net/http/pprof" | |
"time" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```golang | |
package handle | |
import ( | |
"encoding/base64" | |
"fmt" | |
"image" | |
"image/png" | |
"io/ioutil" | |
"log" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"os" | |
"os/signal" | |
"syscall" | |
"time" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func JsonAssignTo(n interface{}, tagName, value string) { | |
sv := reflect.ValueOf(n) | |
if sv.Kind() == reflect.Ptr { | |
//初始化空指针 | |
if sv.IsNil() && sv.CanSet() { | |
sv.Set(reflect.New(sv.Type().Elem())) | |
} | |
sv = sv.Elem() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
// 驼峰式写法转为下划线写法 | |
func hump2Underscore(name string) string { | |
builder:=strings.Builder{} | |
for i, r := range name { | |
if unicode.IsUpper(r) { | |
if i != 0 { | |
builder.WriteByte('_') | |
} | |
builder.WriteRune(unicode.ToLower(r)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
package router | |
import ( | |
"aicloud/common" | |
"bytes" | |
"io" | |
"io/ioutil" | |
"time" | |
"fmt" |