mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-06-24 02:15:50 +08:00
This change was made with the following commands
go mod init
go mod tidy
go mod vendor -v
Revision of github.com/op/go-logging changed because
github.com/anacrolix/torrent requires the current version in its go.mod
# github.com/op/go-logging
yunion.io/x/onecloud/cmd/torrent
github.com/anacrolix/torrent
github.com/elgatito/upnp
github.com/op/go-logging
Content of google.golang.org/grpc changed and it's indeed the case after
checking with the upstream repo. It's very likely that the old content
is wrong.
Some packages like golang.org/x/sys/unix are added because they are
indeeded needed
Some packages are removed as a whole because they are needed anymore
concurrent
- concurrent.Map: backport sync.Map for go below 1.9
- concurrent.Executor: goroutine with explicit ownership and cancellable
concurrent.Map
because sync.Map is only available in go 1.9, we can use concurrent.Map to make code portable
m := concurrent.NewMap()
m.Store("hello", "world")
elem, found := m.Load("hello")
// elem will be "world"
// found will be true
concurrent.Executor
executor := concurrent.NewUnboundedExecutor()
executor.Go(func(ctx context.Context) {
everyMillisecond := time.NewTicker(time.Millisecond)
for {
select {
case <-ctx.Done():
fmt.Println("goroutine exited")
return
case <-everyMillisecond.C:
// do something
}
}
})
time.Sleep(time.Second)
executor.StopAndWaitForever()
fmt.Println("executor stopped")
attach goroutine to executor instance, so that we can
- cancel it by stop the executor with Stop/StopAndWait/StopAndWaitForever
- handle panic by callback: the default behavior will no longer crash your application