Golang

Overview

The Golang generator creates Go structs and Gin-Gonic compatible controllers.

Configuration

Add "golang" to your back-end in config.json:

{
  "back-end": ["golang"]
}

Generated Structure

The Generator will output the following in the go/ directory:

  • models/: Contains Go structs with JSON tags.
  • controllers/: Contains Controller functions for handling HTTP requests.

Model Example

package models

import (
    "time"
)

type User struct {
    Id int64 `json:"id"`
    Name string `json:"name"`
    // ... other fields
}

Controller Example

package controllers

import (
    "net/http"
    "github.com/gin-gonic/gin"
)

type UserController struct{}

func (UserController) Index(c *gin.Context) {
    c.JSON(http.StatusOK, gin.H{"data": "List of User"})
}