filler

package module
v0.0.0-...-2d383ee Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2017 License: MIT Imports: 8 Imported by: 1

README

filler Go Report Card Build Status GoDoc

small util to fill gaps in your structs

Installation

$ go get github.com/yaronsumel/filler

Usage

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fill

func Fill(obj interface{}) error

Fill - fill the object with all the current fillers

func RegFiller

func RegFiller(name string, fn func(obj interface{}) (interface{}, error))

RegFiller - register new filler into []fillers

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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