Skip to content

yaronsumel/filler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

filler Go Report Card Build Status GoDoc

small util to fill gaps in your structs

Installation

$ go get github.com/yaronsumel/filler
package main

import (
	"fmt"
	"github.com/yaronsumel/filler"
)

type model struct {
	UserID   string
	UserName string `fill:"UserNameFiller:UserID"`
}

func init() {
	filler.RegFiller("UserNameFiller", func(value interface{}) (interface{}, error) {
		return "UserId" + value.(string), nil
	})
}

func main() {
	m := &model{
		UserID: "123",
	}
	fmt.Printf("%+v\n", m)
	// should print `&{UserId:123 UserName:}`
	filler.Fill(m)
	// should print `&{UserId:123 UserName:UserId123}`
	fmt.Printf("%+v\n", m)
}
Written and Maintained by @YaronSumel

About

fill struct data easily with fill tags

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages