Skip to content

Instantly share code, notes, and snippets.

View jony4's full-sized avatar
🎯
Focusing

牛强 jony4

🎯
Focusing
View GitHub Profile
@jony4
jony4 / ToUpperCamelCase.go
Last active January 3, 2019 09:04
go ToUpperCamelCase
var camelre = regexp.MustCompile(`_([a-z])`)
// ToUpperCamelCase is an NameFunc that converts strings from snake case to upper camel case.
func ToUpperCamelCase(s string) string {
return strings.ToUpper(string(s[0])) + camelre.ReplaceAllStringFunc(s[1:len(s)], func(s string) string {
return strings.ToUpper(s[1:len(s)])
})
}
@jony4
jony4 / time_parse_bug.go
Created September 29, 2018 07:45
go日期包,parse踩坑
package main
import (
"fmt"
"time"
)
func main() {
t1, _ := time.Parse("2006-01-01", "2010-06-05")
fmt.Println(t1)
@jony4
jony4 / call_user_func_array.go
Last active May 27, 2019 02:00
Likely PHP's call_user_func_array() or Javascritpt's callback(jsonObject)
package main
import (
"errors"
"fmt"
"reflect"
)
func main() {
funcs := map[string]interface{}{"foo": foo, "bar": bar}