add user data generator prompt
parent
28c545f310
commit
e82b99104c
@ -0,0 +1,35 @@
|
||||
Create an application that uses the brianvoe/gofakeit package to generate random data for the following type:
|
||||
|
||||
```go
|
||||
type User struct {
|
||||
UID string `json:"uid"`
|
||||
FirstName string `json:"first_name"`
|
||||
LastName string `json:"last_name"`
|
||||
Status string `json:"status"`
|
||||
ExamID string `json:"exam_id"`
|
||||
}
|
||||
```
|
||||
|
||||
The application should read in a config file called config.json (and call log.Fatalf on any obvious error) of the following type:
|
||||
|
||||
```go
|
||||
type Config struct {
|
||||
NumberOfUsers int `json:"number_of_users"`
|
||||
PercentStatus map[string]int `json:"percent_status"`
|
||||
}
|
||||
```
|
||||
|
||||
Status should be a member of statuses, which is string[]{"JD", "LLM", "MCL", "PHD", "SJD", "MLS", "SPEC", "MNR", "CERT"}
|
||||
|
||||
Check that all the int values in PercentStatus total 100. Use log.Fatalf to end early on an error if they don't.
|
||||
|
||||
Generate a []User equal in length to the value of Config's NumberOfUsers member meeting the following requirements:
|
||||
|
||||
1. ExamID should be a unique random string of 4 digits
|
||||
1. UID should be a unique random string of 10 digits
|
||||
1. members of the []User list should have status in proportion to the entry for status in the PercentStatus config variable
|
||||
1. FirstName should be the result of brianvoe/gofaker FirstName
|
||||
1. LastName should be the result of brianvoe/gofaker LastName
|
||||
|
||||
Output the results to a file called "users.csv". This should be a csv file with the fields in UID, FirstName, LastName, Status, ExameID order.
|
||||
|
||||
Loading…
Reference in New Issue