octolab / pkg Goto Github PK
View Code? Open in Web Editor NEW🧰 Go packages.
Home Page: https://go.octolab.org
License: MIT License
🧰 Go packages.
Home Page: https://go.octolab.org
License: MIT License
research how I can use https://github.com/mvdan/sh instead
e.g. Int64
classifier := errors.Classifier{
"some": []error{x, y, z}
}
class := classifier.Classify(err)
metrics.Count(class).Send()
it checks that reader doesn't have any content anymore
time.TimeoutCorrection(http.Header(req.Header).Timeout(time.Second), 10*time.Millisecond)
import "github.com/Masterminds/semver"
var (
min := fn.MustReturn(semver.NewConstraint(">= 92.0")).(*semver.Constraints)
)
they can be used together.
Lines 58 to 65 in e414a84
https://travis-ci.com/github/octolab/pkg/jobs/350339344
# go.octolab.org/runtime_test [go.octolab.org/runtime.test]
262runtime/caller_test.go:225:4: misplaced compiler directive
263runtime/caller_test.go:229:4: misplaced compiler directive
sync.Times(100).Do(func () {
...
})
os.Interrupt, syscall.SIGINT, syscall.SIGTERM
-> syscall.SIGINT, syscall.SIGTERM
cause os.Interrupt is an alias for syscall.SIGINT
needs to use it in repeatable post requests
safe.Close(resp.Body, ...)
works, but not well. It will be better use something like this:
defer safe.Close(io.Discard(resp.Body), ...)
Lines 11 to 45 in 19e671e
func NewRequest(options ...func(*http.Request)) *http.Request {
req := new(http.Request)
for _, configure := range options {
configure(req)
}
return req
}
func WithForm(kv ...string) func(*http.Request) {
return func(req *http.Request) {
req.Form = make(url.Values, len(kv))
for i := 0; i+1 < len(kv); i += 2 {
req.Form.Set(kv[i], kv[i+1])
}
}
}
func WithHeaders(kv ...string) func(*http.Request) {
return func(req *http.Request) {
req.Header = make(http.Header, len(kv))
for i := 0; i+1 < len(kv); i += 2 {
req.Header.Set(kv[i], kv[i+1])
}
}
}
func WithPath(path string) func(*http.Request) {
return func(req *http.Request) {
req.URL = new(url.URL)
req.URL.Path = path
}
}
global.Classifier.Apply(err, action, errors.Loggable, errors.Critical)
data := helper.Bytes("file:testdata/some.file")
if errors.IsAny(err, Case1, Case2, ...) {}
The concept:
sequence := new(integer.generator).Since(10).Rhythm(func (int64) int64).Until(10^5)
for range sequence.Source() { ... } // math.MaxInt64 by default
sequence.Next() bool
sequence.Current() int64
sequence.FastForward(int64) bool
uid := new(uuid.generator)
uid.Next() string ?
random := new(rand.generator)
random.Next() ?
remove pkg, update vanity url
classificator.Classify(err, fallback) -> classificator.Classify(err)
see kamilsk/breaker#10, in particular go-gitea/gitea#11333
RepeatableReadCloser(
helper.ReadCloser("file:testdata/some.data"),
bytes.NewBuffer(make([]byte, 0, 5)),
)
job := async.NewDelayedJob(make([]func(), 0, 2))
if cond1 {
job.Do(...)
}
if cond2 {
job.Do(...)
}
job.Wait()
wg :=&sync.WaitGroup{}
wg.Add(len(data))
for range data {
go safe.Background(wg, func() { handler.ServeHTTP(rec, &http.Request{}) }, 1)
}
inspiration is here https://github.com/roylee0704/gron/tree/master/xtime
https://golang.org/pkg/runtime/#SetFinalizer
file, err := safe.OpenFile()
if err ...
// no call defer file.Close()
// panic in runtime
how it works
Open() -> SetFinalizer
Close() -> UnsetFinalizer
local := packageX.Classificator.Merge(packageY.Classificator, packageZ.Classificator)
if !local.Consistent() {
panic()
}
add a possibility to filter unique action
e.g. sync.DoUnique(fingerprinter, action)
motivation: log duplicates is not good
if I use io.Discard with defer I have bad dev experience:
resp, err := http.Do(req)
if err {...}
defer safe.Close(io.Discard(resp.Body), ...) // now I can't read from body
json.NewDecoder(resp.Body).Decode() // woops
release, err := sync.Setenvs("A", "b", "C", "d")
...
defer release()
I have to know overhead.
ctx := context.Background()
deadline, has := t.Deadline()
if has {
var cancel context.CancelFunc
ctx, cancel = context.WithDeadline(ctx, deadline.Add(50*time.Millisecond))
defer cancel()
}
to define which nodes never checked to remove it
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.