Skip to content

Instantly share code, notes, and snippets.

View itcuihao's full-sized avatar
🛠️
hello world ~

我的名字叫浩仔 itcuihao

🛠️
hello world ~
View GitHub Profile
@itcuihao
itcuihao / gist:042e00034447ca1111bfafdbdf945e3c
Last active May 10, 2018 13:39
gin print request and response
```
package router
import (
"aicloud/common"
"bytes"
"io"
"io/ioutil"
"time"
"fmt"
```
// 驼峰式写法转为下划线写法
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))
@itcuihao
itcuihao / set value to struct by json tag
Created May 12, 2021 07:20
根据JSON的Tag给结构体赋值
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()
}
@itcuihao
itcuihao / golang kill self
Last active May 17, 2023 12:04
golang kill self
package main
import (
"fmt"
"os"
"os/signal"
"syscall"
"time"
)
@itcuihao
itcuihao / plantuml mindmap
Created June 21, 2023 10:23
golang gen plantuml png
```golang
package handle
import (
"encoding/base64"
"fmt"
"image"
"image/png"
"io/ioutil"
"log"
@itcuihao
itcuihao / golang pprof
Created September 13, 2023 10:53
golang pprof
package common
import (
"fmt"
"net"
"net/http"
_ "net/http/pprof"
"time"
)