Add Make function

This is the important one
This commit is contained in:
Dan Jones 2025-03-10 14:53:59 -05:00
commit 7126ef97a4
2 changed files with 38 additions and 0 deletions

15
make.go Normal file
View file

@ -0,0 +1,15 @@
package nomino
import "fmt"
// Make generates a random filename. The behavior can be controlled by specifying Options
// In general, the final filename will be [prefix]_[generated_string]_[original_filename]_[suffix].[extension].
// If the name generator returns an error (generally, it shouldn't), that will be returned instead.
func Make(conf Config) (string, error) {
name, err := conf.generator()
if err != nil {
return "", err
}
return fmt.Sprintf("%s%s%s%s%s", conf.prefix, name, conf.original, conf.suffix, conf.original), nil
}