All Versions
8
Latest Version
4.3
Avg Release Cycle
32 days
Latest Release
3330 days ago

Changelog History

  • v4.3 Changes

    February 15, 2015

    🚀 This release includes a new -f “force” flag. It allows gen to tolerate certain classes of type-check errors. Learn more…

  • v4.2 Changes

    January 04, 2015

    ➕ Added stringer as a built-in typewriter.

  • v4.1.1 Changes

    December 20, 2014

    🛠 Fix watch error behavior

  • v4.1 Changes

    December 14, 2014

    ➕ Added the watch command, which automatically runs gen on file changes.

  • v4.0.0 Changes

    November 30, 2014

    From the changelog:

    Type parameters

    🏷 Tags now have support for type parameters, for example:

    // +gen foo:"Bar[qux], Qaz[thing, stuff]"
    type MyType struct{}
    

    Those type parameters (qux, thing, stuff) are properly evaluated as types, and passed to your typewriters.

    Type constraints

    Speaking of above, types are evaluated for Numeric, Ordered and Comparable. Templates, in turn, can have type constraints.

    For example, you can declare your Sum template only to be applicable to Numeric types, and your Set to Comparable types.

    gen add

    📦 Third-party typewriters are added to your package using a new command, add. It looks like this:

    gen add github.com/clipperhouse/set
    

    That’s a plain old Go import path.

    After adding, you can mark up a type like:

    // +gen set slice:"GroupBy[string], Select[Foo]"
    type MyType struct{}
    

    As always, it’s up to the third-party typewriter to determine behavior. In this case, a “naked” set tag is enough.

    🗄 We deprecated the unintuitive gen custom command, add replaces it.

    Explcitness

    💅 Previous versions of gen would generate a dozen or so LINQ-style slice methods simply by marking up:

    // +gen
    type MyType struct{}
    

    We’ve opted for explicitness moving forward – in the case of slices, you’ll write this instead:

    // +gen slice:"Where, SortBy, Any"
    type MyType struct{}
    

    In other words, only the methods you want.

    Projections

    Certain methods, such as Select and GroupBy require an additional type parameter. I won’t bore you with the convoluted old way. Now it’s:

    // +gen slice:"GroupBy[string], Select[Foo]"
    type MyType struct{}
    

    Those type parameters are properly evaluated, and typewriters get full type information on them.

    slice

    The main built-in typewriter used to be called genwriter, it is now called slice. Instead of the generated slice type being called Things, it’s now called ThingSlice.

    slice is now the only built-in typewriter.

    🗄 We’ve deprecated the built-in container typewriter, instead splitting it into optional Set, List and Ring typewriters.

    You can add them using the add command described above:

    gen add github.com/clipperhouse/linkedlist
    

    Smaller interface

    For those developing their own typewriters: the TypeWriter interface got smaller. It’s now:

    type TypeWriter interface {
        Name() string
        Imports(t Type) []ImportSpec
        Write(w io.Writer, t Type) error
    }
    

    Validate is gone, it was awkward. The easy fix there was to allow Write to return an error. WriteHeader is gone, there was little use for it in practice. WriteBody is now simply Write.

    We also run goimports on generated code, so if your typewriter only uses the standard library, you might not need to specify anything for Imports() -- they’ll automagically be added to the generated source.

    Let me (@clipperhouse) know if any questions.

  • v3.0.3 Changes

    August 10, 2014

    🐛 Bug fix for pointers: b6ba7bc
    🐛 Bug fix for ‘greater’ func: f5254a8
    🔋 Feature: Go-style error messages with line number, etc: ed75c38

  • v3.0.2 Changes

    August 04, 2014

    📜 A proper tag parser; API unchanged.

  • v3.0.1 Changes

    July 07, 2014

    🐛 Bug fixes