A prototype code-generator library for golang.

go-genial

Go Reference

A prototype code-generator library for golang.

Install

go get github.com/karitham/go-genial

Example

	t := &genial.StructBuilder{}
	t.Comment("Baz is a implementation of Iface").
		Name("Baz").
		Fields(genial.Field{
			Name: "Foo",
			Type: "*string",
			Tag: []genial.StructTag{
				{Type: "json", Value: "foo", Omitempty: true},
			},
		},
		)

	f := &genial.FuncBuilder{}
	f.Comment("FooBar is a new example function").
		Name("FooBar").
		Receiver(genial.Parameter{
			Name: "b",
			Type: "*Baz",
		}).
		Parameters(
			genial.Parameter{
				Name: "foo",
				Type: "int",
			}, genial.Parameter{
				Name: "bar",
				Type: "string",
			},
		).
		ReturnTypes(
			genial.Parameter{
				Type: "int",
			},
			genial.Parameter{
				Type: "error",
			},
		).
		Write([]byte("\tpanic(\"not implemented\")\n"))

	i := &genial.IfaceBuilder{}
	i.Comment("Iface is an example interface").
		Functions(f).Name("Iface")

	p := &genial.PackageBuilder{}

	p.Comment("example is an example package").
		Blocks(t, i, f).
		Name("example")

	fmt.Println(p.String())

generates

// example is an example package
package example

// Baz is a implementation of Iface
type Baz struct {
	Foo *string `json:"foo,omitempty"`
}

// Iface is an example interface
type Iface interface {
	// FooBar is a new example function
	FooBar(foo int, bar string) (int, error)
}

// FooBar is a new example function
func (b *Baz) FooBar(foo int, bar string) (int, error) {
	panic("not implemented")
}
Owner
PL Pery
Student, Nerd, Gamer. Mistake Maker. Looking for an internship (Jan-Apr 22)
PL Pery
Similar Resources

Fast and scalable pseudorandom generator for Go

fastrand Fast pseudorandom number generator. Features Optimized for speed. Performance scales on multiple CPUs. How does it work? It abuses sync.Pool

Dec 22, 2022

Fast, scalable pseudo random number generator based on xxh3

Fast, scalable pseudo random number generator based on xxh3

XXH3-Based Pseudorandom Number Generator This package contains an experimental implementation of a noise based pseudorandom number generator that scal

Nov 24, 2022

Galvanity is Algorand vanity address generator written in Go

Galvanity Galvanity is Algorand vanity address generator written in Go Usage galvanity [search-type] pattern search-type is matching function to sea

Nov 14, 2022

xgen generator with extend features

XGen Plus Generator Introduction xgen is a library written in pure Go providing a set of functions that allow you to parse XSD (XML schema definition)

Dec 8, 2021

Transitland routes geometry generator from gtfs shapes

Transitland route geometry generator Generate your transitland route shapes from gtfs trips - WIP This project aims to generate transitland gtfs route

Dec 8, 2021

Golemon - A Go port of the lemon parser generator

Go lemon port A port of the Lemon Parser to Go. State This work was done entirel

Nov 3, 2022

Rhythm - Euclidean Rhythm generator written in Go with nested circular lists 🤹

rhythm Euclidean Rhythm generator written in Go with nested circular lists 🤹 Us

Jan 31, 2022

Code Generation for Functional Programming, Concurrency and Generics in Golang

goderive goderive derives mundane golang functions that you do not want to maintain and keeps them up to date. It does this by parsing your go code fo

Dec 25, 2022

Golang source code parsing, usage like reflect package

gotype Golang source code parsing, usage like reflect package English 简体中文 Usage API Documentation Examples License Pouch is licensed under the MIT Li

Dec 9, 2022
Code generator that generates boilerplate code for a go http server

http-bootstrapper This is a code generator that uses go templates to generate a bootstrap code for a go http server. Usage Generate go http server cod

Nov 20, 2021
Versatile Go code generator.
Versatile Go code generator.

Generis Versatile Go code generator. Description Generis is a lightweight code preprocessor adding the following features to the Go language : Generic

Nov 30, 2022
Jennifer is a code generator for Go

Jennifer Jennifer is a code generator for Go. package main import ( "fmt" . "github.com/dave/jennifer/jen" ) func main() { f := NewFile("m

Jan 4, 2023
The main goal of this code is to create a basic dnstap printing tool based on the golang-dnstap library.

dnstap-parse The main goal of this code is to create a basic dnstap printing tool based on the golang-dnstap library. The output is supposed to mimic

Nov 14, 2021
Color generator with golang
Color generator with golang

color-generator How to use this repo <img src="https://color-pallete-gen.herokuapp.com/hexCode" /> Like this: Getting Started Copy sample.env to .env

Oct 22, 2021
Rest Api Generator for Golang Programming Language

Rest Api Generator for Golang Programming Language

Nov 29, 2021
Julia Set Generator Written In Golang
 Julia Set Generator Written In Golang

Julia Set Generator Written In Golang This is a simple (naive) Julia Set generator written in Golang. The project utilizes concurrent workers to speed

Nov 5, 2021
Golang Fake data generator

Fake data generator. Written in Go Installation Faker requires Go > 1.17 go get

Nov 16, 2022
Go library that provides fuzzy string matching optimized for filenames and code symbols in the style of Sublime Text, VSCode, IntelliJ IDEA et al.
Go library that provides fuzzy string matching optimized for filenames and code symbols in the style of Sublime Text, VSCode, IntelliJ IDEA et al.

Go library that provides fuzzy string matching optimized for filenames and code symbols in the style of Sublime Text, VSCode, IntelliJ IDEA et al. This library is external dependency-free. It only depends on the Go standard library.

Dec 27, 2022
An enum generator for go

go-enum An enum generator for go How it works The goal of go-enum is to create an easy to use enum generator that will take a decorated type declarati

Dec 22, 2022