github.com/isyscore/isc-gobase@v1.5.3-0.20231218061332-cbc7451899e9/isc/test/struct_test.go (about)

     1  package test
     2  
     3  import (
     4  	"fmt"
     5  	"github.com/isyscore/isc-gobase/isc"
     6  	"reflect"
     7  	"testing"
     8  )
     9  
    10  func TestField(t *testing.T) {
    11  	privateField := PrivateFieldStruct{}
    12  	data := "data"
    13  	isc.SetFieldPrivateValue(reflect.ValueOf(privateField), "name", reflect.ValueOf(&data))
    14  
    15  	dataRel := isc.GetPrivateFieldValue(reflect.ValueOf(&privateField), "name")
    16  	fmt.Println(dataRel)
    17  }
    18  
    19  type PrivateFieldStruct struct {
    20  	name string
    21  	age int
    22  }