You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.3 KiB
Go

package main
import (
"context"
"fmt"
"io"
"os"
"os/signal"
)
// run serves as the "entrypoint" of the application
//
// Operating system fundamentals are passed into run as arguments.
// This makes your programs much easier to test because test code can
// call run to execute your program, controlling arguments, and all
// streams, just by passing different arguments.
//
// Value Type Description
// os.Args []string The arguments passed in when executing your program. Its also used for parsing flags.
// os.Stdin io.Reader For reading input
// os.Stdout io.Writer For writing output
// os.Stderr io.Writer For writing error and logs
// os.Getenv func(string) string For reading environment variables
// os.Getwd func() (string, error) Get the working directory
//
// If you keep away from any global scope data, you can usually use t.Parallel() in more places,
// to speed up your test suites. Everything is self-contained, so multiple calls to run dont
// interfere with each other.
func run(ctx context.Context, w io.Writer, args []string) error {
ctx, cancel := signal.NotifyContext(ctx, os.Interrupt)
defer cancel()
logger := InitLoggging()
return nil
}
func main() {
ctx := context.Background()
if err := run(ctx, os.Stdout, os.Args); err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err)
os.Exit(1)
}
}