github.com/eframework-cn/EP.GO.UTIL@v1.0.0/xos/goid_test.go (about)

     1  //-----------------------------------------------------------------------//
     2  //                     GNU GENERAL PUBLIC LICENSE                        //
     3  //                        Version 2, June 1991                           //
     4  //                                                                       //
     5  // Copyright (C) EFramework, https://eframework.cn, All rights reserved. //
     6  // Everyone is permitted to copy and distribute verbatim copies          //
     7  // of this license document, but changing it is not allowed.             //
     8  //                   SEE LICENSE.md FOR MORE DETAILS.                    //
     9  //-----------------------------------------------------------------------//
    10  
    11  package xos_test
    12  
    13  import (
    14  	"fmt"
    15  	"testing"
    16  
    17  	"github.com/v2pro/plz/reflect2"
    18  )
    19  
    20  func TestGOIDOffset(t *testing.T) {
    21  	gType := reflect2.TypeByName("runtime.g").(reflect2.StructType)
    22  	if gType == nil {
    23  		panic("failed to get runtime.g type")
    24  	}
    25  	goidField := gType.FieldByName("goid")
    26  	goidOffset := goidField.Offset()
    27  	fmt.Println("goid offset: ", goidOffset)
    28  }