Skip to content

go-codegen/go-codegen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-codegen

Overview

go-codegen is a library for generating Go code. It's useful for generating boilerplate code, or code that is tedious to write by hand. It's similar to go-generate, but go-codegen is a library that you can use to generate code, instead of a tool that you run on the command line.

Installation

go get github.com/go-codegen/go-codegen

go install github.com/go-codegen/go-codegen

Usage

Create a entity

type Recipient struct {
	gorm.Model
}

type User struct {
	gorm.Model
	NameAction string `gorm:"unique"`
	Age        int    `codegen:"unique"`
	RecipientID int
	Recipient
}

Create a repository with gorm

go-codegen createRepository gorm --path=test/repository-test.go --out=test/files/

Tags

  • unique - when you create a repository methods, the field will be unique in method find