0%

go-获取变量的类型

go-获取变量的类型:

package main

import (
"fmt"
"github.com/mozillazg/request"
"net/http"
"reflect"
)

func main() {
c := new(http.Client)
req := request.NewRequest(c)

req.Headers = map[string]string{
"Accept-Encoding": "gzip,deflate,sdch",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
}
typeOfX := reflect.TypeOf(req.Headers)

fmt.Println(typeOfX)
}

// 最终打印结果 : map[string]string