Discover Packages
github.com/payfazz/go-mainrun
package
module
Version:
v1.2.0
Opens a new window with list of versions in this module.
Published: Jan 6, 2023
License: MIT
Opens a new window with license information.
Imports: 9
Opens a new window with list of imports.
Imported by: 1
Opens a new window with list of known importers.
README
README
¶
go-mainrun
Utility for main package
How to use
func main() { mainrun.Run(run) }
func run(ctx context.Context) error {
// ...
return nil
}
The ctx passed to run will be cancelled if the program caught os signal
(graceful shutdown).
The returned error will be printed to stderr and the program will be exit
with exit code 1
Expand ▾
Collapse ▴
Documentation
¶
Rendered for
linux/amd64
windows/amd64
darwin/amd64
js/wasm
Go run the f function in new go routine, and return chan to get the value returned by f
similar with Go but returning some value instead of just error
Return nil if graceful shutdown is not requested yet, otherwise return the signal
When function that passed to Run is returned error or panic,
run f, the returned int will be used to os.Exit function.
Run f
The function Run never return.
ctx passed to f will be canceled when graceful shutdown is requested,
if f returned error or panic, then log it and run os.Exit(1), otherwise run os.Exit(0).
type Go2Result[Result any ] struct {
Result Result
Error error
}
Result of Go2
Source Files
¶
Click to show internal directories.
Click to hide internal directories.