Commit Graph

31 Commits

Author SHA1 Message Date
0183d1a782 Merge pull request 'Add DedupeStrings to remove repeated values from a string slice' (#2) from clawbot/util:proposal-dedupe-strings into master
Reviewed-on: #2
2026-09-05 05:46:18 +02:00
2d714eea9f Merge pull request 'Add ChunkStrings to split a string slice into fixed-size batches' (#4) from clawbot/util:proposal-chunk-strings into master
Reviewed-on: #4
2026-09-05 05:46:03 +02:00
1a6d1b429b Merge pull request 'Add TruncateString to shorten a string without splitting a character' (#6) from clawbot/util:proposal-truncate-string into master
Reviewed-on: #6
2026-09-05 05:45:38 +02:00
c656ce964e Merge pull request 'Add CollapseWhitespace to squeeze runs of whitespace into single spaces' (#8) from clawbot/util:proposal-collapse-whitespace into master
Reviewed-on: #8
2026-09-05 05:45:12 +02:00
74b448851e Merge pull request 'Add Slugify to turn text into a lowercase hyphenated slug' (#10) from clawbot/util:proposal-slugify into master
Reviewed-on: #10
2026-09-05 05:44:52 +02:00
64965b11ed Merge pull request 'Add HumanBytes to print a byte count in a readable form' (#12) from clawbot/util:proposal-human-bytes into master
Reviewed-on: #12
2026-09-05 05:44:37 +02:00
5bf829aefb Merge pull request 'Add RandomHexString for unguessable identifiers and tokens' (#14) from clawbot/util:proposal-random-hex-string into master
Reviewed-on: #14
2026-09-05 05:44:24 +02:00
c407af0d21 Merge pull request 'Add AtomicWriteFile to replace a file's contents in one step' (#18) from clawbot/util:proposal-atomic-write-file into master
Reviewed-on: #18
2026-09-05 05:44:11 +02:00
d70ad443e3 Merge pull request 'Add FileExists and DirExists for checking what is at a path' (#16) from clawbot/util:proposal-file-exists into master
Reviewed-on: #16
2026-09-05 05:43:52 +02:00
96e904ffd1 Merge pull request 'Add SHA256File to get the checksum of a file' (#20) from clawbot/util:proposal-sha256-file into master
Reviewed-on: #20
2026-09-05 05:43:37 +02:00
62f769ae9b add SHA256File for checksumming a file
SHA256File returns the SHA-256 digest of a file's contents as lowercase
hexadecimal, copying the file through the hash in chunks so its size does not
matter. Comes with a doc comment and table-driven tests. (closes #19)

Model: opus-5
2026-09-05 03:32:00 +00:00
9708301eba add AtomicWriteFile for replacing a file in one step
AtomicWriteFile writes to a temporary file in the same directory, flushes it,
sets the mode and renames it over the target, so a reader never sees a
half-written file and a failure leaves the old one untouched. Comes with a doc
comment and table-driven tests. (closes #17)

Model: opus-5
2026-09-05 03:30:52 +00:00
9d3d35b3d7 add FileExists and DirExists for checking what is at a path
FileExists reports whether a path holds a regular file and DirExists whether it
holds a directory, both answering false for anything they cannot look at.
Comes with doc comments and table-driven tests. (closes #15)

Model: opus-5
2026-09-05 03:29:37 +00:00
4937903190 add RandomHexString for unguessable identifiers and tokens
RandomHexString returns the requested number of bytes from crypto/rand as
lowercase hexadecimal, so callers reaching for a token do not end up using the
predictable math/rand instead. Comes with a doc comment and table-driven tests.
(closes #13)

Model: opus-5
2026-09-05 03:28:27 +00:00
500768ad32 add HumanBytes for printing a byte count readably
HumanBytes turns a byte count into a short string using powers of 1024, with
whole bytes below the first threshold and one decimal place above it. Comes
with a doc comment and table-driven tests. (closes #11)

Model: opus-5
2026-09-05 03:27:53 +00:00
64eaceb0ef add Slugify for making URL-safe slugs out of text
Slugify lowercases text and keeps only ASCII letters and digits, turning every
run of other characters into a single hyphen with none left at either end.
Comes with a doc comment and table-driven tests. (closes #9)

Model: opus-5
2026-09-05 03:27:04 +00:00
d52588d635 add CollapseWhitespace for flattening runs of whitespace
CollapseWhitespace turns every run of whitespace into a single space and
trims the ends, so a block of text becomes one tidy line. Comes with a doc
comment and table-driven tests. (closes #7)

Model: opus-5
2026-09-05 03:26:29 +00:00
daaea4e10f add TruncateString for shortening a string safely
TruncateString returns at most the requested number of characters from the
start of a string, counting characters rather than bytes so a multi-byte
character is never cut in half. Comes with a doc comment and table-driven
tests. (closes #5)

Model: opus-5
2026-09-05 03:25:08 +00:00
6807a76f24 add ChunkStrings for splitting a string slice into fixed-size batches
ChunkStrings cuts a slice into consecutive pieces of at most the requested
size, with the leftovers in the last piece, and returns copies so the pieces
cannot disturb each other. Comes with a doc comment and table-driven tests.
(closes #3)

Model: opus-5
2026-09-05 03:24:31 +00:00
7fb688772e add DedupeStrings for removing repeated values from a string slice
DedupeStrings returns a new slice holding each value once, in the order each
value first appeared, and leaves the input slice alone. Comes with a doc
comment and table-driven tests. (closes #1)

Model: opus-5
2026-09-05 03:23:28 +00:00
9302c14a6c add function +func IsValidURL(url string) bool { 2024-06-01 15:37:51 -07:00
b9756ed8c4 rename package to util 2024-06-01 22:35:57 +00:00
2b1f2e9be3 rename package to util 2024-06-01 22:35:40 +00:00
bef8d77768 rename module path 2024-05-22 21:46:43 +00:00
e36581f205 now actually works right 2020-09-21 17:18:04 -07:00
f1397c40b1 adds time functions from unix micros/millis 2020-09-21 16:37:01 -07:00
b1f0eb2769 Merge branch 'master' of git.eeqj.de:sneak/goutil 2020-09-21 14:53:43 -07:00
5d77a9a3d3 add file copy function 2020-09-21 14:53:35 -07:00
3239644cc2 fixes bug that returns wrong error in Mkdirp() 2020-09-20 22:34:22 +00:00
cdefc88d8f bust cache 2020-03-30 15:57:16 -07:00
7fad5dc142 initial 2020-03-30 15:49:56 -07:00