From 628f7619ca9a63881e3d68c01b1514c902eba95c Mon Sep 17 00:00:00 2001 From: Oleg Kovalov Date: Thu, 20 Apr 2023 20:29:20 +0200 Subject: [PATCH] Update README, use SelfSignal --- .github/workflows/build.yml | 12 ++++++------ README.md | 16 +++------------- appx.go | 10 +++++----- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 93c6c18..29e63dc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,6 +4,9 @@ on: push: branches: [main] pull_request: + branches: [main] + schedule: + - cron: '0 0 * * 0' # run "At 00:00 on Sunday" workflow_dispatch: inputs: tag: @@ -14,10 +17,7 @@ on: # See https://github.com/cristalhq/.github/.github/workflows jobs: build: - uses: cristalhq/.github/.github/workflows/build.yml@main + uses: cristalhq/.github/.github/workflows/build.yml@v0.5.0 - release: - if: github.event_name == 'workflow_dispatch' - uses: cristalhq/.github/.github/workflows/release.yml@main - with: - tag: ${{ github.event.input.tag }} + vuln: + uses: cristalhq/.github/.github/workflows/vuln.yml@v0.5.0 diff --git a/README.md b/README.md index cc1e711..10501ab 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,6 @@ [![build-img]][build-url] [![pkg-img]][pkg-url] -[![reportcard-img]][reportcard-url] -[![coverage-img]][coverage-url] [![version-img]][version-url] Go library for building applications. Dramatically simple. For a CLI tool see [cristalhq/acmd](https://github.com/cristalhq/acmd). @@ -14,11 +12,11 @@ Go library for building applications. Dramatically simple. For a CLI tool see [c * Dependency-free. * Dramatically simple. -See [GUIDE.md](https://github.com/cristalhq/appx/blob/main/GUIDE.md) for more details +See [these docs][pkg-url] or [GUIDE.md](https://github.com/cristalhq/appx/blob/main/GUIDE.md) for more details. ## Install -Go version 1.17+ +Go version 1.18+ ``` go get github.com/cristalhq/appx @@ -48,11 +46,7 @@ func run(ctx context.Context, args []string) error { } ``` -Also see examples: [examples_test.go](https://github.com/cristalhq/appx/blob/main/example_test.go). - -## Documentation - -See [these docs][pkg-url]. +See examples: [example_test.go](https://github.com/cristalhq/appx/blob/main/example_test.go). ## License @@ -62,9 +56,5 @@ See [these docs][pkg-url]. [build-url]: https://github.com/cristalhq/appx/actions [pkg-img]: https://pkg.go.dev/badge/cristalhq/appx [pkg-url]: https://pkg.go.dev/github.com/cristalhq/appx -[reportcard-img]: https://goreportcard.com/badge/cristalhq/appx -[reportcard-url]: https://goreportcard.com/report/cristalhq/appx -[coverage-img]: https://codecov.io/gh/cristalhq/appx/branch/main/graph/badge.svg -[coverage-url]: https://codecov.io/gh/cristalhq/appx [version-img]: https://img.shields.io/github/v/release/cristalhq/appx [version-url]: https://github.com/cristalhq/appx/releases diff --git a/appx.go b/appx.go index 1220398..521219e 100644 --- a/appx.go +++ b/appx.go @@ -46,8 +46,8 @@ func SetEnv(v string) { // OnSignal run fn. // Function is async, context is used to close underlying goroutine. -func OnSignal(ctx context.Context, signal os.Signal, fn func(ctx context.Context)) { - ch := newChan(signal) +func OnSignal(ctx context.Context, sig os.Signal, fn func(ctx context.Context)) { + ch := newChan(sig) go func() { for { @@ -88,14 +88,14 @@ func BuildInfo() (revision string, at time.Time, isModified, ok bool) { return revision, at, isModified, true } -// SendInterrupt signal to the current process. -func SendInterrupt() error { +// SelfSignal sends signal to the current process. +func SelfSignal(sig os.Signal) error { proc, err := os.FindProcess(os.Getpid()) if err != nil { return fmt.Errorf("unable to find own pid: %w", err) } - if err := proc.Signal(os.Interrupt); err != nil { + if err := proc.Signal(sig); err != nil { return fmt.Errorf("signal: %w", err) } return nil