forked from brianvoe/gofakeit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
file.go
43 lines (34 loc) · 1.35 KB
/
file.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package gofakeit
import "math/rand"
// FileExtension will generate a random file extension
func FileExtension() string { return fileExtension(globalFaker.Rand) }
// FileExtension will generate a random file extension
func (f *Faker) FileExtension() string { return fileExtension(f.Rand) }
func fileExtension(r *rand.Rand) string { return getRandValue(r, []string{"file", "extension"}) }
// FileMimeType will generate a random mime file type
func FileMimeType() string { return fileMimeType(globalFaker.Rand) }
// FileMimeType will generate a random mime file type
func (f *Faker) FileMimeType() string { return fileMimeType(f.Rand) }
func fileMimeType(r *rand.Rand) string { return getRandValue(r, []string{"file", "mime_type"}) }
func addFileLookup() {
AddFuncLookup("fileextension", Info{
Display: "File Extension",
Category: "file",
Description: "Random file extension",
Example: "nes",
Output: "string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return fileExtension(r), nil
},
})
AddFuncLookup("filemimetype", Info{
Display: "File Mime Type",
Category: "file",
Description: "Random file mime type",
Example: "application/json",
Output: "string",
Generate: func(r *rand.Rand, m *MapParams, info *Info) (interface{}, error) {
return fileMimeType(r), nil
},
})
}