datafiller

package module
v0.0.0-...-5b5fda6 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2019 License: MIT Imports: 6 Imported by: 0

README

datafiller

Build Status GoDoc

A Golang package for filling structs by random data.

Installation

go get github.com/erggo/datafiller

Sample Usage

package main

import (
	"encoding/json"
	"fmt"
	"github.com/erggo/datafiller"
)

type S struct {
	A string
	B struct {
		C string
		D string
		E int
	}
}

func main() {
	i := S{}
	datafiller.Fill(&i)
	b, err := json.Marshal(i)
	if err != nil {
		return
	}
	fmt.Println(string(b))
}

TODO

  • simple types
  • structs
  • slices
  • packages
  • simple tagged structs
  • maps
  • smart tagged struct generation
  • guessing names by names
  • add documentation
  • functions
  • all types
  • add options for filling such as slice length

Documentation

Overview

Package datafiller implements function for randomly filling passed datastructures by mock sample data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fill

func Fill(i interface{})

Function Fill takes a pointer to variable of any type and fills the variable by with sample data. It panics if the passed value is not a pointer.

Types

type ArrayMax

type ArrayMax int

func (ArrayMax) AddArg

func (amx ArrayMax) AddArg(f *Filler)

type ArrayMin

type ArrayMin int

func (ArrayMin) AddArg

func (amn ArrayMin) AddArg(f *Filler)

type Filler

type Filler struct {
	Seed int64

	ArrayMin int
	ArrayMax int
	// contains filtered or unexported fields
}

func NewFiller

func NewFiller(args ...FillerArg) *Filler

func (*Filler) Fill

func (f *Filler) Fill(i interface{})

type FillerArg

type FillerArg interface {
	AddArg(*Filler)
}

type Seed

type Seed int64

func (Seed) AddArg

func (sed Seed) AddArg(f *Filler)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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