nomino/make.go
2025-03-11 12:42:03 -05:00

15 lines
546 B
Go

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.extension), nil
}