gogen

package module
v0.0.1-0...-f304f7c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2021 License: MIT Imports: 16 Imported by: 0

README

gogen

CI codecov Go Report Card

A code generator for Go from your code.

Development

  • Following this to install pre-commit
  • Run pre-commit installto set up git hooks for this repository

Documentation

Overview

Package gogen includes logic to generate files using Go template.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Description

type Description struct {
	Name        string
	Pkg         *Package
	Imports     []*Package
	IsInterface bool
	IsStruct    bool
	Methods     []*Method
	Fields      []*Field
}

Description includes parsed information of a Go name. It will be used to feed data to the template.

type Field

type Field struct {
	Name string
	Type *GoType
	Tags map[string]string
}

Field is a field in a struct.

type Generator

type Generator struct {
	Dir          string
	Format       bool
	Name         string
	Output       string
	Template     string
	TemplateFile string
	Writer       io.Writer
	// contains filtered or unexported fields
}

Generator is an execution to generate code. Call Run method to trigger the job.

func (*Generator) Run

func (g *Generator) Run() error

Run executes the generator.

type GoType

type GoType struct {
	Name      string
	IsPointer bool
}

GoType presents a type in Go

func (GoType) String

func (t GoType) String() string

String returns the string presentation.

type Method

type Method struct {
	Name    string
	Params  []*Var
	Results []*Var
}

Method defines a method in Go.

type Package

type Package struct {
	Path string
	Name string
}

Package presents a Go package.

type Var

type Var struct {
	Name string
	Type *GoType
}

Var is a pair of name and Go type to present a variable.

Directories

Path Synopsis
cmd
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL