🚚 Move Slug/Hash Generators to own file
This commit is contained in:
parent
586fe4f1de
commit
1d0f2238b3
7 changed files with 193 additions and 162 deletions
66
gen_file_examples_test.go
Normal file
66
gen_file_examples_test.go
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
package nomino_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"codeberg.org/danjones000/nomino"
|
||||
)
|
||||
|
||||
func ExampleSlug() {
|
||||
conf := nomino.NewConfig(
|
||||
nomino.WithOriginal("My name is Jimmy"),
|
||||
nomino.WithGenerator(nomino.Slug()),
|
||||
)
|
||||
str, _ := nomino.Make(conf)
|
||||
fmt.Println(str)
|
||||
|
||||
// Output: my-name-is-jimmy.txt
|
||||
}
|
||||
|
||||
func ExampleSlug_withLang() {
|
||||
conf := nomino.NewConfig(
|
||||
nomino.WithOriginal("Diese & Dass"),
|
||||
nomino.WithGenerator(nomino.Slug("de")),
|
||||
)
|
||||
|
||||
str, _ := nomino.Make(conf)
|
||||
fmt.Println(str)
|
||||
|
||||
// Output: diese-und-dass.txt
|
||||
}
|
||||
|
||||
func ExampleHash_mD5() {
|
||||
conf := nomino.NewConfig(
|
||||
nomino.WithOriginal("foobar"),
|
||||
nomino.WithGenerator(
|
||||
nomino.Hash(nomino.HashMD5),
|
||||
),
|
||||
)
|
||||
str, _ := nomino.Make(conf)
|
||||
fmt.Println(str)
|
||||
// Output: 3858f62230ac3c915f300c664312c63f.txt
|
||||
}
|
||||
|
||||
func ExampleHash_sHA1() {
|
||||
conf := nomino.NewConfig(
|
||||
nomino.WithOriginal("foobar"),
|
||||
nomino.WithGenerator(
|
||||
nomino.Hash(nomino.HashSHA1),
|
||||
),
|
||||
)
|
||||
str, _ := nomino.Make(conf)
|
||||
fmt.Println(str)
|
||||
// Output: 8843d7f92416211de9ebb963ff4ce28125932878.txt
|
||||
}
|
||||
|
||||
func ExampleHash_sHA256() {
|
||||
conf := nomino.NewConfig(
|
||||
nomino.WithOriginal("foobar"),
|
||||
nomino.WithGenerator(
|
||||
nomino.Hash(nomino.HashSHA256),
|
||||
),
|
||||
)
|
||||
str, _ := nomino.Make(conf)
|
||||
fmt.Println(str)
|
||||
// Output: c3ab8ff13720e8ad9047dd39466b3c8974e592c2fa383d4a3960714caef0c4f2.txt
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue