Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid tag causes infinte loop #349

Closed
KevinJoiner opened this issue Feb 20, 2024 · 2 comments
Closed

Invalid tag causes infinte loop #349

KevinJoiner opened this issue Feb 20, 2024 · 2 comments

Comments

@KevinJoiner
Copy link

When using struct tags that are missing closing brackets, generation hangs indefinitely.
Though this is an invalid tag, it would be helpful to return an error or skip the malformed field.

https://go.dev/play/p/oqXL9XRwykg

package main

import (
	"fmt"

	"github.com/brianvoe/gofakeit/v7"
)

// Create structs with random injected data
type Foo struct {
	RandStr string `fake:"{randomstring:[hello,world}"` // missing closing `]`
       // RandStr string `fake:"{randomstring:[hello,world]}"`
}

func main() {
	var f Foo
	err := gofakeit.Struct(&f)
	if err != nil {
	    panic(err)
	}

	fmt.Println(f.RandStr) 
	fmt.Println("finished")
}
@brianvoe
Copy link
Owner

I actually agree with that!

Let me see if i can add a check for it easily

@brianvoe
Copy link
Owner

Fixed v7.0.1

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

No branches or pull requests

2 participants