Skip to content

Latest commit

 

History

History
42 lines (36 loc) · 1.14 KB

README.md

File metadata and controls

42 lines (36 loc) · 1.14 KB

vincentinttsh/replace

Build Status codecov Go Report Card GoDoc

replace struct value by another struct

package main

import (
	"fmt"

	"github.com/vincentinttsh/replace"
)

func main() {
	var data1 struct {
		Name     string
		UserName string
		Email    string
		Password string
	}
	data1.Name = "user"
	data1.UserName = "user"
	data1.Email = "user"
	data1.Password = "password"
	var data2 struct {
		Name     *string
		UserName *string
		Email    *string
		Password *string
	}
	value := "newuser"
	data2.Name = &value
	fmt.Println(data1)
	replace.replace(&data1, &data2)
	fmt.Println(data1)
}