-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from Cleverse/docs/goref-documents
Add Go-Reference Documents
- Loading branch information
Showing
3 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2023 Cleverse. All rights reserved. | ||
// Use of this source code is governed by a MIT License | ||
// license that can be found in the LICENSE file. | ||
|
||
/* | ||
Package go-utilities provides a miscellaneous useful shared Go packages by [Cleverse]. | ||
# Packages | ||
- [utils]: Minimalist pure Golang optimized generic utilities for Cleverse projects. | ||
- [errors]: Minimalist and zero-dependency errors library with stacktrace support for Go (for wrapping and formatting an errors). | ||
- [queue]: Minimalist and zero-dependency low-level and simple queue library for thread-safe and unlimited-size generics in-memory message queue library fo Go (async enqueue and blocking dequeue supports). | ||
The alternative way to communicate between goroutines compared to `channel` | ||
- [address]: High efficient and minimal utilities library that will help you to work with Ethereum addresses easier. (a [go-ethereum] helper library) | ||
- [fixedpoint]: A [shopspring/decimal] wrapper library for fixed point arithmetic operations in Cleverse projects. | ||
[Cleverse]: https://tip.golang.org/doc/comment#links | ||
[go-ethereum]: https://github.com/ethereum/go-ethereum | ||
[shopspring/decimal]: https://pkg.go.dev/github.com/shopspring/decimal | ||
[utils]: https://pkg.go.dev/github.com/Cleverse/go-utilities/utils | ||
[errors]: https://pkg.go.dev/github.com/Cleverse/go-utilities/errors | ||
[queue]: https://pkg.go.dev/github.com/Cleverse/go-utilities/queue | ||
[address]: https://pkg.go.dev/github.com/Cleverse/go-utilities/address | ||
[fixedpoint]: https://pkg.go.dev/github.com/Cleverse/go-utilities/fixedpoint | ||
*/ | ||
package goutilities |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
# Examples | ||
Basic usage: | ||
q := New[string]() | ||
q.Enqueue("Foo") | ||
item, ok := q.Dequeue() | ||
if !ok { | ||
panic("item should be dequeued") | ||
} | ||
fmt.Println(item) // Output: Foo | ||
Concurrency usage: | ||
q := New[string]() | ||
go func() { | ||
for { | ||
item, ok := q.Dequeue() | ||
if !ok { | ||
break | ||
} | ||
fmt.Println(item) | ||
} | ||
}() | ||
data := []string{"Foo", "Bar", "Baz"} | ||
for _, item := range data { | ||
q.Enqueue(item) | ||
} | ||
q.Close() // close queue to stop goroutine | ||
Queue is unlimited capacity, so you can enqueue as many as you want without blocking or dequeue required: | ||
q := New[string]() | ||
for i := 0; i < 1000000; i++ { | ||
q.Enqueue("Foo") | ||
} | ||
*/ | ||
package queue |