Skip to content

Instantly share code, notes, and snippets.

View Dockerfile
# 直接用 official image,可以省下很多工
FROM php:7.4.9-fpm-alpine
COPY php.ini $PHP_INI_DIR/conf.d/
# 安裝 php extensions 的神器,請務必一試!
# https://github.com/mlocati/docker-php-extension-installer
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/bin/
RUN install-php-extensions redis mysqli xdebug
View comparison_2.go
a := map[string]interface{} {"name": "Charlie", "age": 20}
b := map[string]interface{} {"name": "Charlie", "age": 20}
fmt.Printf("a: %v\nb: %v\nDeepEqual:%v\n", a, b, reflect.DeepEqual(a, b))
fmt.Printf("(%T) %v\n", b["age"], b["age"])
err := json.Unmarshal([]byte(`{"name": "Charlie", "age": 20}`), &b)
if err != nil {
panic("oops")
}
fmt.Printf("a: %v\nb: %v\nDeepEqual:%v\n", a, b, reflect.DeepEqual(a, b))
View comparison_1.go
a := map[string]interface{} {"name": "Charlie", "age": 20}
b := map[string]interface{} {"name": "Charlie", "age": 20}
fmt.Printf("a: %v\nb: %v\nDeepEqual:%v\n", a, b, reflect.DeepEqual(a, b))
err := json.Unmarshal([]byte(`{"name": "Charlie", "age": 20}`), &b)
if err != nil {
panic("oops")
}
fmt.Printf("a: %v\nb: %v\nDeepEqual:%v\n", a, b, reflect.DeepEqual(a, b))
View test.go
func main() {
//str := "能解此愁,唯有杜康!"
//str := `"{"data":"中文"}"`
str := []byte(`"{"data":"中文"}"`)
fmt.Printf("string: %s\n", str)
//fmt.Println("String length:", len([]rune(str)))
fmt.Println("String length:", len([]byte(str)))
fmt.Println(" Bytes length:", len(str))
fmt.Println("------------------------------------")
fmt.Println("cnt index rune char bytes")