// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. // // This Source Code Form is subject to the terms of the MIT License. // If a copy of the MIT was not distributed with this file, // You can obtain one at https://github.com/gogf/gf. package gutil import ( "context" ) // Go creates a new asynchronous goroutine function with specified recover function. // // The parameter `recoverFunc` is called when any panic during executing of `goroutineFunc`. // If `recoverFunc` is given nil, it ignores the panic from `goroutineFunc` and no panic will // throw to parent goroutine. // // But, note that, if `recoverFunc` also throws panic, such panic will be thrown to parent goroutine. func Go( ctx context.Context, goroutineFunc func(ctx context.Context), recoverFunc func(ctx context.Context, exception error), ) { if goroutineFunc == nil { return } go TryCatch(ctx, goroutineFunc, recoverFunc) }