Comments (8)
Hi @halturin,
Can you please provide a use-case or explanation for what you want to see? I just don't understand what is the result what you want to get from gofakeit.
from gofakeit.
Thanks for your reply.
i'm just expecting to see kind of [][]float32{nil, []float32{...}, nil, nil} or something. Currently, it fills all the values of any slice.
from gofakeit.
As far as I know this is the closest solution, but it's not generating nil values:
package main
import (
"fmt"
"github.com/brianvoe/gofakeit/v6"
)
func main() {
v := [][]float32{nil, []float32{12}, nil}
gofakeit.Slice(&v)
fmt.Println(v)
// Output: [[6.5598885e+37 2.9083515e+38 1.9996555e+38 7.870126e+37 3.2749926e+37 2.658292e+38 1.0501455e+38] [1.4212272e+38] [1.647583e+38 2.382803e+38 3.0777828e+38 1.395749e+38 1.610417e+38]]
}
I think this requires some modification on the Slice function.
from gofakeit.
Unfortunately, it doesn't work. Imagine a multidimensional slice, say [][][][][]float32.
It would be great if the Slice method could check the item type using CanAddr method
from gofakeit.
@halturin I know it does not work, because I said: "I think this requires some modification on the Slice function."
This means that the Slice function does not support such a requirement, so someone needs to add this functionality. :)
Also probably it will be a new function, because of backward compatibility.
from gofakeit.
The problem with this is if i randomized a nil in an array of []float32 I would get the same issue from others wondering why im only partially filling out the array.
This is more of a user issue than anything. Sounds like you should make your own lookup function and output it the way you want.
from gofakeit.
Thanks for the reply. As soon as a slice/map can be nil, it's weird not to have the ability to assign nil as a value. It would be great to have another method like gofakeit.SliceWithNil(...) to add the probability of nil values. Up to you.
from gofakeit.
Im good. Thanks.
from gofakeit.
Related Issues (20)
- Adding other delimiters for the CSVOptions HOT 2
- randomint is missing in function lookup HOT 3
- How to Sample strings based on file HOT 1
- time.Time pointers in structs yield zero values or nil
- Test Issue
- Returning errors from gofakeit.Fakeable HOT 7
- package github.com/brianvoe/gofakeit/v6: cannot find package "github.com/brianvoe/gofakeit/v6" in any of: HOT 1
- Improve data HOT 1
- Better Descriptions HOT 6
- gofakeit.date() generate different date when using same seed. HOT 4
- Generate some data with custom template function HOT 3
- Avoid circular dependencies without changing struct definition (for generated proto types)? HOT 1
- wrong game dice example
- Date Parsing Error with Single-Digit Months in CreatedFormat Field HOT 1
- Inconsistency in fake data generation while changing the order of Struct's properties. HOT 6
- Invalid tag causes infinte loop HOT 2
- UUID generates the same values over and over again. HOT 4
- Stackoverflow on cyclicly linked structures HOT 1
- How to generate fake data from specific country/language? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gofakeit.