github.com/lemon-mint/libuseful@v1.3.1-0.20220724073654-ee73785d5aa0/example/dumpstruct/dumpstruct.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"unsafe"
     6  
     7  	"github.com/lemon-mint/libuseful"
     8  )
     9  
    10  type s1 struct {
    11  	Exported1 int  `json:"aaa"`
    12  	Exported2 bool `json:"bbb"`
    13  
    14  	unExported1 int
    15  	unExported2 bool
    16  }
    17  
    18  func main() {
    19  	a := s1{
    20  		Exported1:   12345678,
    21  		Exported2:   true,
    22  		unExported1: 87654321,
    23  		unExported2: true,
    24  	}
    25  	var buf = make([]byte, int(unsafe.Sizeof(a)))
    26  	fmt.Println(libuseful.DumpStruct(buf, &a))
    27  }