🧐 What is this?
elle (Elegant Low-Level Elements) is a lightweight Go library designed to simplify coding for me.
It provides a set of utilities and methods that make Go development faster and more efficient, especially for complex operations.
✨ Features
- 🧼 Simple - Very simple syntax that makes coding fun
- 🚀 Fast - Zero-overhead model to abstractions & any sugar in syntax
- 🛡️ Secure - Built from the ground up to be cryptographically secure
- ✨ Robust - Variety of use-cases and methods for all types of projects
📝 Example
package main
import (
"time"
"github.com/exact/elle/io"
"github.com/exact/elle/random"
"github.com/exact/elle/types"
)
// Create a global, synced pool that can be used anywhere
var pool = io.SyncPool(30)
func main() {
// A zero-size, empty struct is included for efficiency
test := make(chan types.None, 1)
test <- types.None{}
// Simulate a panicing function, it will recover automatically
pool.Go(func() {
time.Sleep(3 * time.Second)
panic("something went horribly wrong!")
})
// Simulate a random amount of I/O work
for i := range random.Number(25, 50) {
pool.Go(func() {
resp, err := io.Request("GET", "https://example.com/", nil, nil, true)
if err != nil {
io.Log.Warn("Request Failed", "thread", i)
} else {
io.Log.Info("Request Done", "thread", i, "resp", resp)
}
})
}
// Wait for all work to finish
pool.Wait()
}