Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Not working with interface type? #83

Closed
mangatmodi opened this issue Dec 16, 2019 · 1 comment
Closed

Not working with interface type? #83

mangatmodi opened this issue Dec 16, 2019 · 1 comment

Comments

@mangatmodi
Copy link

I am using faker/v3 module. I understand that faker doesn't work with interface{}, however in the following code

package main

import (
	"fmt"
	"github.com/bxcodec/faker/v3"
)

type Request struct {
	Headers    map[string][]string
	Body       []byte
	StatusCode int
	Status     string
	Err        error
}

func main() {
	r := &Request{}
	err := faker.FakeData(r)
	fmt.Println(err)
}

I am getting interface{} not allowed error. I don't have any interface{} type element in the struct. The only interface is error, all others are collection type.

@mangatmodi mangatmodi changed the title interface{} not allowed for non interface types? > V3.0.0 not working with interfaces any more Dec 17, 2019
@mangatmodi mangatmodi changed the title > V3.0.0 not working with interfaces any more V3.1.0+ not working with interfaces any more Dec 17, 2019
@mangatmodi mangatmodi changed the title V3.1.0+ not working with interfaces any more not working with interface type? Dec 17, 2019
@mangatmodi mangatmodi changed the title not working with interface type? Not working with interface type? Dec 17, 2019
@mangatmodi
Copy link
Author

Ok, so error is of type interface. With Nil value faker can't tell which concrete implementation to use, hence the error. It is expected. I was dumb to realise is so late.

Maybe in wiki we should edit it from interface{} to interface with nil values to make it more clear to people?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant