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

Set does not report errors #54

Open
licaonfee opened this issue Dec 16, 2024 · 0 comments
Open

Set does not report errors #54

licaonfee opened this issue Dec 16, 2024 · 0 comments

Comments

@licaonfee
Copy link
Contributor

Given the following code

package main

import (
	"fmt"

	"github.com/creasty/defaults"
)

type Kitten struct {
	MaxHP int `default:"powerfull"`
}

func main() {
	var k Kitten
	if err := defaults.Set(&k); err != nil {
		panic(fmt.Sprintf("Bad Kitty %v", err))
	} else {
		fmt.Printf("Good Kitty %#v\n", k)
	}
}

It prints "Good Kitty main.Kitten{MaxHP:0}" , I think Set should return an error in this case

Playground link https://go.dev/play/p/KUi5L1hP-IF

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

1 participant