moredefaults

package module
v0.0.0-...-17d1318 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2024 License: MIT Imports: 6 Imported by: 1

README

moredefaults

This is a simple fork of https://github.com/creasty/defaults that supports tags other than default.

Usage:

moredefaults.Set(&obj)            // uses the "default" tag
moredefaults.Set(&obj, "example") // uses the "example" tag

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanUpdate

func CanUpdate(v interface{}) bool

CanUpdate returns true when the given value is an initial value of its type

func MustSet

func MustSet(ptr interface{}, name ...string)

MustSet function is a wrapper of Set function It will call Set and panic if err not equals nil.

func Set

func Set(ptr interface{}, name ...string) error

Set initializes members in a struct referenced by a pointer. Maps and slices are initialized by `make` and other primitive types are set with default values. `ptr` should be a struct pointer

Types

type Setter

type Setter interface {
	SetDefaults()
}

Setter is an interface for setting default values

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL