Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mafulong/godal
godal provides the ability to generate specific golang code. The godal is to enable developers to write fast code in an expressive way.
https://github.com/mafulong/godal
go golang gorm gorm-model orm
Last synced: about 1 month ago
JSON representation
godal provides the ability to generate specific golang code. The godal is to enable developers to write fast code in an expressive way.
- Host: GitHub
- URL: https://github.com/mafulong/godal
- Owner: mafulong
- License: mit
- Created: 2021-03-16T03:09:34.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-10-23T04:38:11.000Z (about 3 years ago)
- Last Synced: 2024-08-03T19:10:02.444Z (5 months ago)
- Topics: go, golang, gorm, gorm-model, orm
- Language: Go
- Homepage:
- Size: 97.7 KB
- Stars: 18
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go-extra - godal - 03-16T03:09:34Z|2021-10-23T04:38:11Z| (Go Generate Tools / Routers)
README
[![GoDoc](https://godoc.org/github.com/mafulong/godal?status.svg)](https://pkg.go.dev/github.com/mafulong/godal)
[![Codecov.io](https://codecov.io/github/mafulong/godal/coverage.svg?branch=main)](https://codecov.io/github/mafulong/godal?branch=main)
[![Go Report Card](https://goreportcard.com/badge/github.com/mafulong/godal)](https://goreportcard.com/report/github.com/mafulong/godal)
[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)godal
===[English](README.md) | [中文](README_CN.md)
godal provides the ability to generate specific golang code. The goal is to enable developers to write fast code in an
expressive way.Functions:
1. Generate orm model corresponding to golang by specifying sql ddl file, which can be used by gorm.
2. Update latergodal has been added to [awesome-go](https://awesome-go.com/), [MR link](https://github.com/avelino/awesome-go/pull/3857/)
## Usage Documentation## Installation
Using this package requires a working Go
environment. [See the install instructions for Go](http://golang.org/doc/install.html).Go Modules are required when using this
package. [See the go blog guide on using Go Modules](https://blog.golang.org/using-go-modules).How to install godal?
```shell
git clone [email protected]:mafulong/godal.git
cd godal
go install
```Make sure that you can have result when call commend`which godal`
## SQL to golang model
```shell
godal gen model --database {your databaseName} {your sqlFile}
```### Example
You can enter the test directory in this repo.
```shell
godal gen model --database testdb gen_model.sql
```[What you can get?](https://github.com/mafulong/godal/test/model/)
example file1:
```go
package testdbimport "time"
type TestTb1 struct {
TestId int `gorm:"Column:test_id" json:"test_id"`
TestTitle string `gorm:"Column:test_title" json:"test_title"`
TestAuthor string `gorm:"Column:test_author" json:"test_author"`
SubmissionDate time.Time `gorm:"Column:submission_date" json:"submission_date"`
}func (TestTb1) TableName() string {
return "test_tb1"
}```
## License
The MIT License (MIT). Please see [License File](LICENSE) for more information.