docstrings for many functions.

This commit is contained in:
fiatjaf
2025-03-04 11:08:31 -03:00
parent a82780e82e
commit 5bfaed2740
22 changed files with 293 additions and 66 deletions

View File

@@ -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 {