Skip to content

Commit

Permalink
Update README, use SelfSignal
Browse files Browse the repository at this point in the history
  • Loading branch information
cristaloleg committed Apr 20, 2023
1 parent dde7684 commit 628f761
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 24 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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/[email protected]
16 changes: 3 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
10 changes: 5 additions & 5 deletions appx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 628f761

Please sign in to comment.