users_test.go
600 字节
package model
import (
"github.com/tiptok/gocomm/common"
domain "github.com/tiptok/godevp/pkg/domain/users"
"testing"
"time"
"unsafe"
)
func TestUsers(t *testing.T) {
var u = &Users{}
var user = &domain.Users{
Name: "tiptok",
Phone: "1886018",
Roles: []int64{7, 8},
Status: 1,
CreateTime: time.Now(),
}
// 方法一:直接赋值
u.Name = &(user.Name)
// 方法二:使用unsafe.Pointer
u.Status = (*int)(unsafe.Pointer(&user.Status))
// 方法三: json-transfer
common.JsonUnmarshal(common.JsonAssertString(user), u)
if *(u.Name) != "tiptok" {
}
}