8000 panic when field of type map[string]any is in the struct · Issue #30 · go-faker/faker · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
panic when field of type map[string]any is in the struct #30
Closed
@lev112

Description

@lev112

given this struct

type MyStruct struct {
	A string
	B map[string]any
}

the following code will fail

var base MyStruct
err := faker.FakeData(&base) 

with an error:

interface{} not allowed

(this is how I would expect it to behave)

if I try to ignore the fields that include an interface:

var base MyStruct
err := faker.FakeData(&base,
	options.WithIgnoreInterface(true),
)

I would expect the faking to work, and leave the B field empty,
but the code will panic with

panic: runtime error: invalid memory address or nil pointer dereference


adding

options.WithFieldsToIgnore("B")

will solve that problem, but the panic is very confusing,
and there is no hint of what is the problem

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0