Skip to content
| Marketplace
Sign in
Visual Studio Code>Formatters>DDL 2 Go StructNew to Visual Studio Code? Get it now.

DDL 2 Go Struct

Wandecilenio Martins

|
2,431 installs
| (0) | Free
Convert the DDL instructions to Go Struct
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

DDL 2 Go Struct

This is a simple tool to convert the DDL instructions to a struct in Goland using the SQL package.

The steps is simple.

First select the ddl create table instructions, example:

CREATE TABLE public.t_customer
(
  id serial NOT NULL PRIMARY KEY,
  name character varying(255) NOT NULL,
  document character varying(20) NOT NULL,

  created_at timestamp(0) without time zone NOT NULL DEFAULT now(),
  updated_at timestamp(0) without time zone
);

Then type CTRL+SHIFT+p

And run the DDL2GS: Convert the DDL instructions to Go Struct to convert the sql text selected to go struct

Or just select it and press CTRL+SHIFT+i

Will result in:

// Customer --
type Customer struct {
	ID	int64	`db:"id"`
	Name	string	`db:"name"`
	Document	string	`db:"document"`
	CreatedAT	*time.Time	`db:"created_at"`
	UpdatedAT	*time.Time	`db:"updated_at"`
}

Enjoy!

  • Contact us
  • Jobs
  • Privacy
  • Terms of use
  • Trademarks
© 2023 Microsoft