mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-11-19 10:36:42 +01:00
docstrings for many functions.
This commit is contained in:
6
utils.go
6
utils.go
@@ -7,6 +7,7 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// IsValidRelayURL checks if a URL is a valid relay URL (ws:// or wss://).
|
||||
func IsValidRelayURL(u string) bool {
|
||||
parsed, err := url.Parse(u)
|
||||
if err != nil {
|
||||
@@ -18,6 +19,7 @@ func IsValidRelayURL(u string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// IsValid32ByteHex checks if a string is a valid 32-byte hex string.
|
||||
func IsValid32ByteHex(thing string) bool {
|
||||
if !isLowerHex(thing) {
|
||||
return false
|
||||
@@ -29,6 +31,7 @@ func IsValid32ByteHex(thing string) bool {
|
||||
return err == nil
|
||||
}
|
||||
|
||||
// CompareEvent is meant to to be used with slices.Sort
|
||||
func CompareEvent(a, b Event) int {
|
||||
if a.CreatedAt == b.CreatedAt {
|
||||
return strings.Compare(a.ID, b.ID)
|
||||
@@ -36,6 +39,7 @@ func CompareEvent(a, b Event) int {
|
||||
return cmp.Compare(a.CreatedAt, b.CreatedAt)
|
||||
}
|
||||
|
||||
// CompareEventReverse is meant to to be used with slices.Sort
|
||||
func CompareEventReverse(b, a Event) int {
|
||||
if a.CreatedAt == b.CreatedAt {
|
||||
return strings.Compare(a.ID, b.ID)
|
||||
@@ -43,6 +47,7 @@ func CompareEventReverse(b, a Event) int {
|
||||
return cmp.Compare(a.CreatedAt, b.CreatedAt)
|
||||
}
|
||||
|
||||
// CompareEventPtr is meant to to be used with slices.Sort
|
||||
func CompareEventPtr(a, b *Event) int {
|
||||
if a == nil {
|
||||
if b == nil {
|
||||
@@ -60,6 +65,7 @@ func CompareEventPtr(a, b *Event) int {
|
||||
return cmp.Compare(a.CreatedAt, b.CreatedAt)
|
||||
}
|
||||
|
||||
// CompareEventPtrReverse is meant to to be used with slices.Sort
|
||||
func CompareEventPtrReverse(b, a *Event) int {
|
||||
if a == nil {
|
||||
if b == nil {
|
||||
|
||||
Reference in New Issue
Block a user