Skip to content

Commit

Permalink
add CommandString, HasErrFunc, LogHasErr, PrintHasErr, DiscardHasErr
Browse files Browse the repository at this point in the history
  • Loading branch information
kokizzu committed Oct 20, 2022
1 parent 38d8d83 commit 24ec7cf
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 1,149 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,18 @@ daemon.Start(cmdId) // use "go" keyword if you need non-blocking version
// ^ by default will only run next command if previous command exited
// if you want to run them in parralel, use daemon.StartParallel().Wait()

daemon.CommandString(cmdId) // returns "sleep 2"
```

## FAQ

Q: Why not just channel? why callback?

A: Because channel requires a consumer or it would stuck/block, while callback doesn't (this is why I add flag to activate the channel API). To the Percona reviewer that rejected me because I didn't use channel at the first time "the whole thing is written in JavaScript translated to Go, not in Go. Technical task does not adhere to Go best practices which is what would expect from the candidate. One example was that the code is written in JS-like style (e.g. callback). Go code does not use callback like node.js for example", well, jokes on you XD
A: Because channel requires a consumer, or it would stuck/block if channel is full, while callback doesn't (this is why I add flag to activate the channel API). To the Percona reviewer that rejected me because I didn't use channel at the first time "the whole thing is written in JavaScript translated to Go, not in Go. Technical task does not adhere to Go best practices which is what would expect from the candidate. One example was that the code is written in JS-like style (e.g. callback). Go code does not use callback like node.js for example", well, jokes on you XD

Q: How to ignore error?

A: assign `goproc.HasErrFunc` with `goproc.DiscardHasErr`, other option are: `L.IsError` (default), `goproc.LogHasErr` (uses log), `goproc.PrintHasErr` (uses fmt)

## TODO

Expand Down
19 changes: 11 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
module github.com/kokizzu/goproc

go 1.17
go 1.18

require github.com/kokizzu/gotro v1.1726.1724
require github.com/kokizzu/gotro v1.2028.1837

require (
github.com/fatih/color v1.13.0 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/goccy/go-json v0.9.11 // indirect
github.com/klauspost/cpuid/v2 v2.1.2 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 // indirect
github.com/rogpeppe/go-internal v1.8.1 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/yosuke-furukawa/json5 v0.1.1 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
golang.org/x/crypto v0.1.0 // indirect
golang.org/x/sys v0.1.0 // indirect
)
Loading

0 comments on commit 24ec7cf

Please sign in to comment.