lxc / incus

Powerful system container and virtual machine manager
https://linuxcontainers.org/incus
Apache License 2.0
2.78k stars 224 forks source link

Use `maps.Clone()` where appropriate #1391

Closed montag451 closed 5 days ago

montag451 commented 5 days ago

Go 1.21 introduced a new maps package which provides some utility functions to facilitate some common operations on map. One of these functions is maps.Clone which eases the cloning of a map. Moreover, the maps.Clone function is slightly more efficient than manual cloning (cf https://github.com/golang/go/commit/b5a7f2eef7cb17255cb396cd4ff7df04957dd21e)

montag451 commented 5 days ago

I missed the fact that maps.Clone return a nil map when the passed map is nil which lead to crashes in some parts of the code so I prefer to close the PR because the benefit of using maps.Clone is not as high as expected.