<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>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ~~~ 不可尋址 常量的值。 基本類型值的字面量。 算術操作的結果值。 對各種字面量的索引表達式和切片表達式的結果值。不過有一個例外,對切片字面量的索引結果值卻是可尋址的。 對字符串變量的索引表達式和切片表達式的結果值。 對字典變量的索引表達式的結果值。 函數字面量和方法字面量,以及對它們的調用表達式的結果值。 結構體字面量的字段值,也就是對結構體字面量的選擇表達式的結果值。 類型轉換表達式的結果值。 類型斷言表達式的結果值。 接收表達式的結果值。 ~~~ * [https://www.jianshu.com/p/c85fc3e31249](https://www.jianshu.com/p/c85fc3e31249) ~~~ package main //unsafe.Pointer:通用指針類型,用于轉換不同類型的指針,不能進行指針運算 //uintptr:用于指針運算,GC 不把 uintptr 當指針,uintptr 無法持有對象。uintptr 類型的目標會被回收 //unsafe.Pointer 可以和 uintptr 進行相互轉換 import ( "unsafe" "fmt" ) type T struct { t1 byte t2 int32 t3 int64 t4 string t5 bool } func main() { t := &T{1, 2, 3, "this is a example", true} ptr := unsafe.Pointer(t) t1 := (*byte)(ptr) fmt.Println(*t1) fmt.Println("-------------------------") //unsafe.Offsetof 函數用于獲取兩個值在內存中的起始存儲地址之間的偏移量,以字節為單位。 t2 := (*int32)(unsafe.Pointer(uintptr(ptr) + unsafe.Offsetof(t.t2))) *t2 = 99 fmt.Println(t) fmt.Println("-------------------------") t3 := (*int64)(unsafe.Pointer(uintptr(ptr) + unsafe.Offsetof(t.t3))) fmt.Println(*t3) fmt.Println("-------------------------") *t3 = 123 fmt.Println(t) fmt.Println("-------------------------") } ~~~ > ### 其它例子 ~~~ package main import ( "unsafe" "fmt" ) func main() { number1 := make([]int, 2, 2) fmt.Println(&number1[1]) //結構體偏移量用這個:Offsetof, slice偏移量:Sizeof 詳細看方法說明 ptr2 := (*int)(unsafe.Pointer(uintptr(unsafe.Pointer(&number1[0])) + unsafe.Sizeof(1))) fmt.Println(ptr2) } ~~~ > ### 相關閱讀 * [Go語言學習筆記--unsafe.Pointer 和 uintptr](https://blog.csdn.net/cbmljs/article/details/82983639)
                  <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>

                              哎呀哎呀视频在线观看