Skip to content
This repository has been archived by the owner on Aug 2, 2019. It is now read-only.

ldez/go-capillarity

Repository files navigation

Go Capillarity

Build Status godoc

A simple object filler.

Examples

  • Basic case:

    type MyStruct struct {
    	Foo string
    	Bar struct {
    		One string
    		Two string
    	}
    }
    
    myStruct := MyStruct{}
    
    capil := capillarity.NewCapillarity()
    err := capil.Fill(&myStruct)
    if err != nil {
    	log.Fatal(err)
    }
    
    fmt.Printf("%+v", myStruct)
    
    // output: {Foo:foobar Bar:{One:foobar Two:foobar}}
  • With options:

    type MyStruct struct {
    	Foo string
    	Bar struct {
    		One string
    		Two int
    	}
    }
    
    myStruct := MyStruct{}
    
    capil := capillarity.NewCapillarity(capillarity.WithDefaultString("go"), capillarity.WithDefaultNumber(6))
    err := capil.Fill(&myStruct)
    if err != nil {
    	log.Fatal(err)
    }
    
    fmt.Printf("%+v", myStruct)
    
    // output: {Foo:go Bar:{One:go Two:6}}