1
0
mirror of https://github.com/lxc/go-lxc.git synced 2026-02-05 06:46:38 +01:00

Do not copy the underlying mutex

This changes the return type of 3 functions. This should be safe
assuming the expected usage of those functions in the form of;

```
c := lxc.DefinedContainers(lxcpath)
...
```

Should help to #82 as well
This commit is contained in:
S.Çağlar Onur
2017-09-16 15:27:33 -07:00
parent edfe59cec2
commit 379087f32b
2 changed files with 10 additions and 10 deletions

View File

@@ -26,8 +26,8 @@ import (
// Container struct
type Container struct {
container *C.struct_lxc_container
mu sync.RWMutex
container *C.struct_lxc_container
verbosity Verbosity
}

View File

@@ -116,12 +116,12 @@ func ContainerNames(lxcpath ...string) []string {
// Containers returns the defined and active containers on the system. Only
// containers that could retrieved successfully are returned.
func Containers(lxcpath ...string) []Container {
var containers []Container
func Containers(lxcpath ...string) []*Container {
var containers []*Container
for _, v := range ContainerNames(lxcpath...) {
if container, err := NewContainer(v, lxcpath...); err == nil {
containers = append(containers, *container)
containers = append(containers, container)
}
}
@@ -151,12 +151,12 @@ func DefinedContainerNames(lxcpath ...string) []string {
// DefinedContainers returns the defined containers on the system. Only
// containers that could retrieved successfully are returned.
func DefinedContainers(lxcpath ...string) []Container {
var containers []Container
func DefinedContainers(lxcpath ...string) []*Container {
var containers []*Container
for _, v := range DefinedContainerNames(lxcpath...) {
if container, err := NewContainer(v, lxcpath...); err == nil {
containers = append(containers, *container)
containers = append(containers, container)
}
}
@@ -186,12 +186,12 @@ func ActiveContainerNames(lxcpath ...string) []string {
// ActiveContainers returns the active containers on the system. Only
// containers that could retrieved successfully are returned.
func ActiveContainers(lxcpath ...string) []Container {
var containers []Container
func ActiveContainers(lxcpath ...string) []*Container {
var containers []*Container
for _, v := range ActiveContainerNames(lxcpath...) {
if container, err := NewContainer(v, lxcpath...); err == nil {
containers = append(containers, *container)
containers = append(containers, container)
}
}