Eric's cool utilities for Go development!
ericool
is a collection of utilities for Go development, created by Eric Xiao. It includes various packages that provide functionalities such as assertions for unit testing, consistent hashing, logging, task pooling, and file batch processing.
- Assertion utilities for unit testing
- Consistent hashing implementation
- Logging utilities with different log levels and output options
- Task pooling for managing concurrent tasks
- File batch processing utilities
- Go (Golang)
To install the ericool
package, you can use go get
:
go get github.com/ericxiao417/ericool
Here are some examples of how to use the different modules in the ericool
package.
import "github.com/ericxiao417/ericool/assert"
func TestEqual(t *testing.T) {
assert.Equal(t, expected, actual)
}
import "github.com/ericxiao417/ericool/consistenthash"
ch := consistenthash.New(1000)
ch.Add("node1", "node2", "node3")
node, err := ch.Get("key")
import "github.com/ericxiao417/ericool/ericlog"
ericlog.Infof("This is an info message")
import "github.com/ericxiao417/ericool/taskpool"
pool, _ := taskpool.NewPool()
pool.Go(func(param ...interface{}) {
// Task code here
})
import "github.com/ericxiao417/ericool/filebatch"
err := filebatch.Walk("/path/to/dir", true, ".txt", func(path string, info os.FileInfo, content []byte, err error) []byte {
// Process file content here
return content
})
Provides assertion utilities for unit testing.
Provides functions for big-endian and little-endian binary encoding and decoding.
Implements consistent hashing.
Provides logging utilities with different log levels and output options.
Provides utilities for testing, such as fake time and fake OS exit.
Provides utilities for batch processing files.
Provides a task pool for managing concurrent tasks.
Contributions are welcome! Please follow these steps to contribute:
- Fork the repository
- Create a new branch (
git checkout -b feature/your-feature
) - Commit your changes (
git commit -m 'Add some feature'
) - Push to the branch (
git push origin feature/your-feature
) - Open a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Name: Eric Xiao
- GitHub: ericxiao417