<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## int操作和結構體操作 ``` package main import ( "fmt" "reflect" ) //對int反射 func reflectTest01(b interface{}) { //1.獲取reflect.Type rTyp := reflect.TypeOf(b) ? ? fmt.Printf("rType=%v\n", rTyp) //rType=int //2.獲取reflect.value rVal := reflect.ValueOf(b) ? ? fmt.Printf("rValue=%v rValue的類型是%T\n", rVal, rVal) //rValue=100 rValue的類型是reflect.Value n2 := rVal.Int() + 2 //將reflect.value轉回int ? ? fmt.Println("n2=", n2) //n2 = 102 //將rval轉成interface{} iv := rVal.Interface() num2 := iv.(int) ? ? fmt.Println("num2=", num2) } //對結構體反射 func reflectTest02(b interface{}) { //1.獲取reflect.Type rTyp := reflect.TypeOf(b) ? ? fmt.Printf("rType=%v\n", rTyp) //rType=int //2.獲取reflect.value rVal := reflect.ValueOf(b) ? ? fmt.Printf("rValue=%v rValue的類型是%T\n", rVal, rVal) //rValue=100 rValue的類型是reflect.Value //3.獲取變量對應的kind //(1)rVal.Kind() kind1 := rVal.Kind() //(2) rTyp.Kind() kind2 := rTyp.Kind() ? ? fmt.Printf("kind=%v kind=%v\\n", kind1, kind2) //kind=struct kind=struct //將rval轉成interface{} iv := rVal.Interface() ? ? fmt.Printf("iv=%v iv type=%T\n", iv, iv) //此時無法取出name age value, ok := iv.(Student) if !ok { return //轉換失敗 ? ? } fmt.Printf("name%v age=%v\n", value.Name, value.Age) } type Student struct { Name string Age ?int } func main() { num := 100 reflectTest01(num) stu := Student{"Tom", 20} reflectTest02(stu) } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看