Skip to content

hackirby/upstruct

Folders and files

NameName
Last commit message
Last commit date

Latest commit

93dd904 · Sep 20, 2023

History

2 Commits
Sep 20, 2023
Sep 20, 2023
Sep 20, 2023
Sep 20, 2023
Sep 20, 2023
Sep 20, 2023

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