poc/

directory
v0.71.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: MIT

README

SDK generator PoC

PoC of generating full object implementation based on object definition.

Description

There is an example file ready for generation database_role_def.go which creates files:

How it works

Creating object generation definition

To create definition for object generation:

  1. Create file object_name_def.go (like example database_role_def.go file).
  2. Put go generate directive at the top: //go:generate go run ../main.go. Remember that you may have to change the path to main.go file.
  3. Create object interface definition.
  4. Add key-value entry to definitionMapping in main.go:
  5. You are all set to run generation.
Invoking generation

To invoke example generation (with first cleaning all the generated files) run:

make clean-generator-poc run-generator-poc

Next steps

Essentials
  • use DSL to build object definitions (from branch go-builder-dsl) - ideally leave two options of defining objects and proceed with generation based on definition provided
  • differentiate between different actions implementations (now only Create and Alter has been considered, Show on the other hand has totally different implementation)
  • generate structs for Show and ShowID
  • handle arrays
  • handle more validation types
Improvements
  • automatic names of nested structs (e.g. DatabaseRoleRename)
  • check if generating with package name + invoking format removes unnecessary qualifier
  • consider merging templates StructTemplate and OptionsTemplate (requires moving Doc to Field)
  • add unit tests to this generator
Known issues
  • spaces in templates (especially nested validations)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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