diff options
| author | Bobby <[email protected]> | 2025-07-17 18:47:30 +0530 |
|---|---|---|
| committer | Bobby <[email protected]> | 2025-07-17 18:47:30 +0530 |
| commit | 8df8cdd7e1bdefded59d073c14aa74666740be8c (patch) | |
| tree | 0af31475e1a5ffecd04a9fbce3faf5cd6bf80140 /utils/format | |
| parent | 3c39a30a53656fa1c51afb30bb8c07f862bd39e2 (diff) | |
| download | imageboard-8df8cdd7e1bdefded59d073c14aa74666740be8c.tar.xz imageboard-8df8cdd7e1bdefded59d073c14aa74666740be8c.zip | |
tags and ratings filter in posts, uploads progress
Diffstat (limited to 'utils/format')
| -rw-r--r-- | utils/format/image.go | 14 | ||||
| -rw-r--r-- | utils/format/numbers.go | 9 |
2 files changed, 23 insertions, 0 deletions
diff --git a/utils/format/image.go b/utils/format/image.go new file mode 100644 index 0000000..b68271c --- /dev/null +++ b/utils/format/image.go @@ -0,0 +1,14 @@ +package format + +import ( + "imageboard/config" + "strings" +) + +func GetCDNURL() string { + cdnURL := strings.TrimRight(config.S3.PublicURL, "/") + "/" + config.S3.BucketName + if config.S3.FolderPath != "" { + cdnURL += "/" + config.S3.FolderPath + } + return cdnURL +} diff --git a/utils/format/numbers.go b/utils/format/numbers.go index 8f546f1..b1561e5 100644 --- a/utils/format/numbers.go +++ b/utils/format/numbers.go @@ -18,3 +18,12 @@ func Int64ToString(value int64) string { } return fmt.Sprintf("%d", value) } + +func StringToUint(value string) (uint, error) { + var uintValue uint + _, err := fmt.Sscanf(value, "%d", &uintValue) + if err != nil { + return 0, fmt.Errorf("invalid string to uint conversion: %w", err) + } + return uintValue, nil +} |
