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

Stack overflow occurs when a struct embeds a non-exported struct #915

Closed
marselester opened this issue Dec 1, 2023 · 4 comments · Fixed by #917
Closed

Stack overflow occurs when a struct embeds a non-exported struct #915

marselester opened this issue Dec 1, 2023 · 4 comments · Fixed by #917
Labels
bug Issues describing a bug in go-toml.

Comments

@marselester
Copy link

Stack overflow occurs when a struct embeds a non-exported struct.

package main

import (
	toml "github.com/pelletier/go-toml/v2"
)

func main() {
	b := []byte(`
fizz = "..."
blah.a = "..."`)
	var cfg config
	if err := toml.Unmarshal(b, &cfg); err != nil {
		panic(err)
	}
}

type config struct {
	Fizz string `toml:"fizz"`
	blah `toml:"blah"`
}

type blah struct {
	A string `toml:"a"`
}

I would expect Unmarshal to return an error.

Versions

  • go-toml: v2.1.0
  • go: go1.21.3
  • operating system: macOS, Linux
@pelletier pelletier added the bug Issues describing a bug in go-toml. label Dec 3, 2023
@pelletier
Copy link
Owner

Thank you for the bug report!

@pelletier
Copy link
Owner

This should have been fixed at the tip of the v2 branch. Feel free to re-open if anything doesn't work as expected!

@pelletier
Copy link
Owner

Pushed go-toml v2.1.1 with this fix.

@marselester
Copy link
Author

Awesome, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues describing a bug in go-toml.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants