mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
go fix: use (*sync.WaitGroup).Go
Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
This commit is contained in:
committed by
Kir Kolyshkin
parent
99d054b93f
commit
47fba7e4b1
@@ -53,16 +53,14 @@ information is displayed once every 5 seconds.`,
|
|||||||
events = make(chan *types.Event, 1024)
|
events = make(chan *types.Event, 1024)
|
||||||
group = &sync.WaitGroup{}
|
group = &sync.WaitGroup{}
|
||||||
)
|
)
|
||||||
group.Add(1)
|
group.Go(func() {
|
||||||
go func() {
|
|
||||||
defer group.Done()
|
|
||||||
enc := json.NewEncoder(os.Stdout)
|
enc := json.NewEncoder(os.Stdout)
|
||||||
for e := range events {
|
for e := range events {
|
||||||
if err := enc.Encode(e); err != nil {
|
if err := enc.Encode(e); err != nil {
|
||||||
logrus.Error(err)
|
logrus.Error(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
})
|
||||||
if context.Bool("stats") {
|
if context.Bool("stats") {
|
||||||
s, err := container.Stats()
|
s, err := container.Stats()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -117,17 +117,13 @@ func handleSingle(path string, noStdin bool) error {
|
|||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
inErr, outErr error
|
inErr, outErr error
|
||||||
)
|
)
|
||||||
wg.Add(1)
|
wg.Go(func() {
|
||||||
go func() {
|
|
||||||
_, outErr = io.Copy(os.Stdout, c)
|
_, outErr = io.Copy(os.Stdout, c)
|
||||||
wg.Done()
|
})
|
||||||
}()
|
|
||||||
if !noStdin {
|
if !noStdin {
|
||||||
wg.Add(1)
|
wg.Go(func() {
|
||||||
go func() {
|
|
||||||
_, inErr = io.Copy(c, os.Stdin)
|
_, inErr = io.Copy(c, os.Stdin)
|
||||||
wg.Done()
|
})
|
||||||
}()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only close the master fd once we've stopped copying.
|
// Only close the master fd once we've stopped copying.
|
||||||
|
|||||||
Reference in New Issue
Block a user