atlas-hcl-gen-go

command module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: MIT Imports: 15 Imported by: 0

README

atlas-hcl-gen-go

This is a command to generate Go struct from Atlas HCL Schema.

Usage

Install the command.

go install github.com/ucpr/atlas-hcl-gen-go

Generate Go struct from Atlas HCL Schema.

atlas-hcl-gen-go -f schema.hcl -o output.go

Example

The input data uses the schema written in HCL below.

schema "market" {}

table "users" {
  schema = schema.market
  column "name" {
    type = text
  }
  column "updated_at" {
    type = int
  }
  column "created_at" {
    type = int
  }
}

Execute the command.

atlas-hcl-gen-go -i schema.hcl -o output.go

The following Go struct will be generated.

// Code generated by github.com/ucpr/atlas-hcl-gen-go. DO NOT EDIT.
// atlas-hcl-gen-go: 922707f-dirty
// source: testdata/schema.hcl

package main

type Users struct {
	Name      int `db:"name"`
	UpdatedAt int `db:"updated_at"`
	CreatedAt int `db:"created_at"`
}

TODO

  • Support some types
  • Support some RDBMS schemas (MySQL, PostgreSQL, SQLite, ...)

Contributing

Contributions of any kind welcome!

License

MIT License

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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