English | 简体中文
op
is a Go utility toolkit that provides a variety of reusable packages for common programming tasks. Each package is designed to be lightweight, efficient, and easy to integrate into your projects. This repository serves as a centralized entry point for all sub-packages.
The toolkit includes the following packages:
A generic double-ended queue (deque) implementation.
- Features: Push/pop from both ends, generic support.
- Usage: See deque/README.md or deque/README_zh.md for details.
A generic event emitter for pub/sub patterns.
- Features: Event subscription, once listeners, async/sync emission, panic recovery.
- Constraints: Event type must be
comparable
. - Usage: See emission/README.md.
A LINQ-style query library for Go slices.
- Features: Filtering, mapping, sorting, grouping, and more.
- Usage: See linq/README.md (if exists).
Tools for managing external processes.
- Features: Process execution, stdout/stderr handling, process management.
- Files:
process.go
: Core process handling.process_m.go
: Process manager for multiple processes.
- Usage: See process/README.md or process/README_zh.md.
A generic slice wrapper with utility methods.
- Features: Push, pop, filter, map, reduce, etc.
- Usage: See slice/README.md or slice/README_zh.md.
A string wrapper with common operations.
- Features: Contains, split, replace, case conversion, etc.
- Usage: See str/README.md (if exists).
A worker pool for concurrent task execution.
- Features: Fixed-size worker pool, task submission.
- Usage: See workerpool/README.md or workerpool/README_zh.md.
A generator package
To use the op
toolkit in your Go project, run:
go get github.com/wsshow/op
Then import the desired packages:
import "github.com/wsshow/op"
package main
import (
"fmt"
"github.com/wsshow/op"
)
func main() {
// Create a string
s := op.NewString("Hello, World")
fmt.Println(s.Contain("World")) // true
// Create a slice
sl := op.NewSlice(1, 2, 3)
fmt.Println(sl.Data()) // [1 2 3]
// Create an event emitter
em := op.NewEmitter[string]()
em.On("event", func(args ...string) {
fmt.Println("Event:", args)
})
em.Emit("event", "test") // Event: [test]
}
op/
├── deque/ # Double-ended queue
├── emission/ # Event emitter
├── linq/ # LINQ-style queries (multiple instances)
├── process/ # Process management (multiple instances)
├── slice/ # Slice utilities (multiple instances)
├── str/ # String utilities
├── workerpool/ # Worker pool
└── op.go # Toolkit entry point