https://github.com/mingderwang/ginger
go generate tool to create a RESTful API micro server from a Json data schema
https://github.com/mingderwang/ginger
Last synced: about 1 year ago
JSON representation
go generate tool to create a RESTful API micro server from a Json data schema
- Host: GitHub
- URL: https://github.com/mingderwang/ginger
- Owner: mingderwang
- License: other
- Created: 2015-08-14T15:34:51.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2016-09-15T16:43:21.000Z (almost 10 years ago)
- Last Synced: 2025-03-25T08:01:50.652Z (over 1 year ago)
- Language: Go
- Size: 31.3 KB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Ginger - for go generate a micro service from data schema
Add following line in top of your data schema file
// go:generate gigner $GOFILE
and also add following line above each data type you want to build api
// @ginger
then, type "go generate"
# Example data schema file
You can generate following data type from JSON-to-Go online tool with a sample of your data object in Json format. (http://mholt.github.io/json-to-go/)
Ginger will generate main.go for you, only need a dataType.go in the current folder.
Please add following 2 lines in your data schema
Ginger_Created int32 `json:"ginger_created,omitempty"`
Ginger_Id int32 `json:"ginger_id,omitempty"`
For example, User Schema
```go
//go:generate ginger $GOFILE
package main
//@ginger
type User struct {
Ginger_Created int32 `json:"ginger_created"`
Ginger_Id int32 `json:"ginger_id" gorm:"primary_key"`
ID string `json:"id"`
Name string `json:"name"`
Deleted bool `json:"deleted"`
Status interface{} `json:"status"`
Color string `json:"color"`
RealName string `json:"real_name"`
Tz string `json:"tz"`
TzLabel string `json:"tz_label"`
TzOffset int `json:"tz_offset"`
Profile struct {
RealName string `json:"real_name"`
RealNameNormalized string `json:"real_name_normalized"`
Email string `json:"email"`
Image24 string `json:"image_24"`
Image32 string `json:"image_32"`
Image48 string `json:"image_48"`
Image72 string `json:"image_72"`
Image192 string `json:"image_192"`
} `json:"profile"`
IsAdmin bool `json:"is_admin"`
IsOwner bool `json:"is_owner"`
IsPrimaryOwner bool `json:"is_primary_owner"`
IsRestricted bool `json:"is_restricted"`
IsUltraRestricted bool `json:"is_ultra_restricted"`
IsBot bool `json:"is_bot"`
HasFiles bool `json:"has_files"`
Has2Fa bool `json:"has_2fa"`
}
```
#Demo
refer to github.com/mingderwang/goslack