ericool

module
v0.0.0-...-c5e7aac Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 22, 2025 License: MIT

README

ericool

GoDoc

Eric's cool utilities for Go development!

Table of Contents

Introduction

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.

Features

  • 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

Technologies

  • Go (Golang)

Installation

To install the ericool package, you can use go get:

go get github.com/ericxiao417/ericool

Usage

Here are some examples of how to use the different modules in the ericool package.

Assertions
import "github.com/ericxiao417/ericool/assert"

func TestEqual(t *testing.T) {
    assert.Equal(t, expected, actual)
}
Consistent Hashing
import "github.com/ericxiao417/ericool/consistenthash"

ch := consistenthash.New(1000)
ch.Add("node1", "node2", "node3")
node, err := ch.Get("key")
Logging
import "github.com/ericxiao417/ericool/ericlog"

ericlog.Infof("This is an info message")
Task Pool
import "github.com/ericxiao417/ericool/taskpool"

pool, _ := taskpool.NewPool()
pool.Go(func(param ...interface{}) {
    // Task code here
})
File Batch Processing
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
})

Modules

assert

Provides assertion utilities for unit testing.

bele

Provides functions for big-endian and little-endian binary encoding and decoding.

consistenthash

Implements consistent hashing.

ericlog

Provides logging utilities with different log levels and output options.

fake

Provides utilities for testing, such as fake time and fake OS exit.

filebatch

Provides utilities for batch processing files.

taskpool

Provides a task pool for managing concurrent tasks.

Contributing

Contributions are welcome! Please follow these steps to contribute:

  1. Fork the repository
  2. Create a new branch (git checkout -b feature/your-feature)
  3. Commit your changes (git commit -m 'Add some feature')
  4. Push to the branch (git push origin feature/your-feature)
  5. Open a pull request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

Directories

Path Synopsis
package assert 提供了单元测试时的断言功能,减少一些模板代码
package assert 提供了单元测试时的断言功能,减少一些模板代码
非阻塞协程池,协程数量可动态增长,可配置最大协程并发数量,可手动释放空闲的协程
非阻塞协程池,协程数量可动态增长,可配置最大协程并发数量,可手动释放空闲的协程

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL