Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/influx6/moz
Flexible codegen in go
https://github.com/influx6/moz
annotations code-generation codegenerator function-composition gen go gocodegenerator moz
Last synced: about 1 month ago
JSON representation
Flexible codegen in go
- Host: GitHub
- URL: https://github.com/influx6/moz
- Owner: influx6
- License: mit
- Created: 2017-05-21T22:17:45.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-29T18:42:56.000Z (over 6 years ago)
- Last Synced: 2024-06-21T14:12:15.290Z (6 months ago)
- Topics: annotations, code-generation, codegenerator, function-composition, gen, go, gocodegenerator, moz
- Language: Go
- Size: 1.63 MB
- Stars: 8
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
Moz
=======
Moz exists has a library to provide a solid foundation for code generation by combining functional composition and Go ast for flexible content creation.Install
-----------```shell
go get -u github.com/influx6/moz
```Introduction
----------------------------Moz is a code generator which builds around the concepts of pluggable `io.WriteTo` elements that allow a elegant but capable system for generating code programmatically.
It uses functional compositions to define code structures that connect to create contents and using the Go ast parser, generates elegant structures for easier interaction with source files.
Features
----------- Basic Programming structures
- Simple Coding Blocks
- Go text/template support
- Annotation code generationProjects Using Moz
--------------------- [Gu](https://github.com/gu-io/gu)
- [Dime](https://github.com/influx6/dime)Code Generation with Moz
--------------------------Moz is intended to be very barebones and minimal, it focuses around providing very basic structures, that allows the most flexibility in how you generate new content.
It provides two packages that are the center of it's system:
## [Gen](./gen)
Gen provides compositional structures for creating content with functions.
#### Generate Go struct using [Gen](./gen)
```go
import "github.com/influx6/moz/gen"floppy := gen.Struct(
gen.Name("Floppy"),
gen.Commentary(
gen.Text("Floppy provides a basic function."),
gen.Text("Demonstration of using floppy API."),
),
gen.Annotations(
"Flipo",
"API",
),
gen.Field(
gen.Name("Name"),
gen.Type("string"),
gen.Tag("json", "name"),
),
)var source bytes.Buffer
floppy.WriteTo(&source) /*
// Floppy provides a basic function.
//
// Demonstration of using floppy API.
//
//
//@Flipo
//@API
type Floppy struct {Name string `json:"name"`
}
*/
```Contributors
----------------
Please feel welcome to contribute with issues and PRs to improve Moz. :)