Skip to content

hackirby/upstruct

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

upstruct GoDoc

upstruct is an utility package to update a golang struct with another one

Install

go get github.com/hackirby/upstruct

Example

import "github.com/hackirby/upstruct"

type User struct {
    Username string
    Password string
}

type UserPatch struct {
    Username string
    Password string
}

var user = User{
    Username: "user",
    Password: "password",
}

var userPatch = UserPatch{
    Username: "newuser",
    Password: "newpassword",
}

func main() {
    upstruct.Update(&user, userPatch)
}

About

Update a struct with another one in Go

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages