Skip to content

Commit

Permalink
Leverage struct copy by value in clone
Browse files Browse the repository at this point in the history
  • Loading branch information
silphid committed May 17, 2021
1 parent cd9f9cb commit efccd7e
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/internal/ctx/ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,12 @@ func Load(file string) (Context, error) {

// Clone returns a deep-copy of this context
func (c Context) Clone() Context {
clone := Context{
Container: c.Container,
Name: c.Name,
Image: c.Image,
Env: make(map[string]string),
Mounts: make(map[string]string),
}
clone := c
clone.Env = make(map[string]string)
for key, value := range c.Env {
clone.Env[key] = value
}
clone.Mounts = make(map[string]string)
for key, value := range c.Mounts {
clone.Mounts[key] = value
}
Expand Down

0 comments on commit efccd7e

Please sign in to comment.