Skip to content

Set does not report errors  #54

@licaonfee

Description

@licaonfee

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions