https://github.com/hyperjumptech/go-utility
Utility library to easily work on common logic
https://github.com/hyperjumptech/go-utility
Last synced: 7 months ago
JSON representation
Utility library to easily work on common logic
- Host: GitHub
- URL: https://github.com/hyperjumptech/go-utility
- Owner: hyperjumptech
- License: gpl-3.0
- Created: 2024-08-07T06:27:52.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-07T06:44:10.000Z (almost 2 years ago)
- Last Synced: 2025-01-20T06:32:57.034Z (over 1 year ago)
- Language: Go
- Size: 19.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# HyperUtility
## Data structure
Simple implementation of **Stack** and **Queue** data structure.
Both structure were backend with array of `[]interface{}`
### Stack
Implement the Stack data structure FILO (First In Last Out).
In stack, the first data added into the stack can only
be retrieved the latest, and the last added data into the stack
can be retrieved immediately.
```text
+---+---+---+---+ <--- push
| 1 | 2 | 3 | n |
+---+---+---+---+ ---> pop
```
### Queue
Implement the Queue data structure FIFO (First In First Out).
In Queue, the first data added into the Queue can be
retrieved immediately, and the last added data into the stack
can be retrieved the latest.
```text
+---+---+---+---+
pop <--- | 1 | 2 | 3 | n | <--- push
+---+---+---+---+
```
## io.Writer
### MultipleWriter
MultipleWriter easily write byte stream into multiple write stream.
Its very useful for the case like writing multiple log,
for example, one to the console `os.StdErr` and one to
some external file writer.
```text
+--> writer_a.Write()
|
multiWriter.Write() ---+
|
+--> writer_b.Write()
```