All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Types of changes:
Security
in case of vulnerabilities.Removed
for now removed features.Deprecated
for soon-to-be removed features.Added
for new features.Changed
for changes in existing functionality.Fixed
for any bug fixes.Internal
for changes that are worth noting, but don't have any external effects.
This is not a breaking change from the prior version (0.7.1) but rather a solidification of the existing API and a commitment not to break it going forward. The API has been stable and is use for over 2 years, so this seems reasonable. If a breaking change is necessary in the future, it will require a major version bump.
--runtime
command line flag - identifies the Go runtime version used to build the executable.- #5 Support anonymous function signatures as parameters.
- When passing multiple files as command line arguments, load packages once for the whole execution instead of once per file, resulting in a massive speedup when processing many files as loading packages is the slowest part of the process.
- Fixed
$.AddImportType
failing on certain go types:- interface literals
- struct type literals
- maps
- functions signatures
- New template function,
catNoSpace
, that concatenates multiple strings together into one with no separators between them. This complements the already includedcat
function from Sprig http://masterminds.github.io/sprig/strings.html which joins with a space in between each string.
- New template function
isExported
that detects if a name is private or exported.
- The template function
typeString
has been moved to a context method$.TypeString
in order to prevent including the package in the type string if it is part of the current package.
- The current package is now always prevented from being imported into the
generated file, even if it is passed to
AddImport
. - Fixed parsing of the "codegen" tags to be compatible with go 1.17.
- New template context method
$.AddImportType
which takes a type object instead of a string. - New template method
typeString
which returns the full go representation of the type, including '*' for pointers, '[]' for slices, etc.
typeName
no longer panics for basic types that don't have a package:int
,string
, etc.
-v
command line flag that prints the version number and exits.
- A new template context method
$.RequireArg
which returns the value of a template argument if it was provided, and fails the generation if the argument was not provided. - A new template context method
$.DefaultArg
which returns the value of a template argument if it was provided, and a default value (second parameter passed toDefaultArg
) if the template argument was not provided.
- The template method
typeName
now correctly returns the name of pointer types (without the asterisk). - The template method
structField
can now return un-exported fields in addition to exported fields.
- A new template method
structFields
which returns an array of the fields (type[]*types.Var
) declared on the passed struct. Note that this doesn't include fields elevated from embedded types.
- The template variable
.Struct
is now an instance of*types.Named
instead of*types.Struct
. This is necessary to inspect the methods on the struct as they are tied to the named type, not the underlying struct.
This is where we formally began tracking changes.