Compare commits

...

4 commits

Author SHA1 Message Date
5cbd63a227 🔀 Merge branch 'release/0.5.2' into stable 2025-03-23 10:55:05 -05:00
ac3d1a5565 💡 Add package level doc comment 2025-03-23 10:53:49 -05:00
c32a15f4a1 💡 Add some helpful comments in example 2025-03-23 10:52:54 -05:00
4b9bffb1a6 🔀 Merge tag 'v0.5.1' into develop
🔖 Bump version just to publish example
2025-03-19 18:47:40 -05:00
2 changed files with 12 additions and 2 deletions

View file

@ -17,8 +17,10 @@ func NominoConfig() nomino.Config {
) )
} }
// / HandleImgUploads generates new filenames for images with a png extension. // HandleImgUploads generates new filenames for images with a png extension.
func HandleImgUploads(orig string) string { func HandleImgUploads(orig string) string {
// Here, we use nomino.Make function to generate the filename.
// We use our global config, and add in a few extra Options specific to this.
newName, _ := nomino.Make( newName, _ := nomino.Make(
NominoConfig(), NominoConfig(),
nomino.WithExtension("png"), nomino.WithExtension("png"),
@ -32,6 +34,8 @@ func HandleImgUploads(orig string) string {
// We ignore the original filename and use a timestamp for the generated part // We ignore the original filename and use a timestamp for the generated part
// with a webm extension. // with a webm extension.
func HandleVidUploads() string { func HandleVidUploads() string {
// Because we're using a different Generator, we chose to use the Make method on the Generator.
// We add in additional Options with the `AddOptions` method on the `Config`
newName, _ := nomino.Timestamp(nomino.TimestampUTC()). newName, _ := nomino.Timestamp(nomino.TimestampUTC()).
MakeWithConfig(NominoConfig().AddOptions( MakeWithConfig(NominoConfig().AddOptions(
nomino.WithExtension("webm"), nomino.WithExtension("webm"),
@ -39,7 +43,7 @@ func HandleVidUploads() string {
return newName return newName
} }
// Example shows how to use nomino. // This example shows how to use nomino.
func Example() { func Example() {
// Pretend we have an image upload // Pretend we have an image upload
filename := "George" filename := "George"

6
nomino.go Normal file
View file

@ -0,0 +1,6 @@
// Package nomino is a utility that allows us to generate random filenames.
//
// There are two main methods of using nomino.
// 1. Using the `nomini.Make` function.
// 2. Creating a generator, and using its `Make` method.
package nomino