/constr

Make constructors for any Go types

Primary LanguageGo

Simple utility to generate constructors in Go for types

Usage

Given a file abc.go with the following content

package test

import "io"

type Something struct {
	some   string
	writer io.Writer
}

Running the following command

constr -t Something abc.go

would change the abc.go file to the following

package test

import "io"

type Something struct {
	some   string
	writer io.Writer
}

func NewSomething(some string,
	writer io.Writer) *Something {
	return &Something{some: some,
		writer: writer}
}