Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/utgwkk/rowstructgen
https://github.com/utgwkk/rowstructgen
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/utgwkk/rowstructgen
- Owner: utgwkk
- License: mit
- Created: 2023-04-27T13:50:39.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-11T11:33:30.000Z (7 months ago)
- Last Synced: 2024-04-20T08:59:57.988Z (7 months ago)
- Language: Go
- Size: 58.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rowstructgen
## Usage
```sql
-- schema.sql
CREATE TABLE `users` (
`id` BIGINT UNSIGNED NOT NULL,
`name` VARCHAR(255) NOT NULL,
`deleted_at` DATETIME NULL,
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARACTER SET=utf8mb4;```
```sh
$ rowstructgen -schema schema.sql -table users -package row -out row/user.go
``````go
// row/user.go
package rowimport "time"
type User struct {
Id uint64 `db:"id"`
Name string `db:"name"`
DeletedAt *time.Time `db:"deleted_at"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
}
```