DEV Community

Cover image for A Powerful Golang Productivity Tool, Golang can also “Low-Code Development”
zhuyasen
zhuyasen

Posted on • Updated on

A Powerful Golang Productivity Tool, Golang can also “Low-Code Development”

sponge is a powerful golang productivity tool that integrates automatic code generation, web and microservices frameworks, basic development framework. sponge has a wealth of generating code commands, generating different functional code can be combined into a complete service (similar to the way that artificially broken sponge cells can automatically recombine into a new sponge). The code is decoupled and modularly designed, it is easy to build a complete project from development to deployment, so that you develop web or microservices project easily, golang can also be "low-code development".

If you are developing a web or microservice with a simple CRUD API interface, you don't need to write a single line of golang code to compile and deploy to servers, dockers, k8s, and the complete service code is generated by sponge.

If you develop a generic web or microservice, you need to manually write code in addition to defining the data table, defining the api interface in the proto file, and filling in the specific business logic code in the generated template file. Other golang codes are generated by sponge.

Repo:https://github.com/zhufuyi/sponge

Docs:https://go-sponge.com/

sponge generates the code framework

sponge is mainly based on SQL and Protobuf two ways to generate code, each way has to generate code for different functions.

Generate code framework:

Image description

Generate code framework corresponding UI interface:

Image description

Services framework

sponge generated microservice code framework is shown in the figure below, which is a typical microservice hierarchical structure, with high performance, high scalability, contains commonly used service governance features, you can easily replace or add their own service governance features.

Image description

Egg model for complete service code

The sponge separates the two major parts of code during the process of generating web service code. It isolates the business logic from the non-business logic. For example, consider the entire web service code as an egg. The eggshell represents the web service framework code, while both the albumen and yolk represent the business logic code. The yolk is the core of the business logic (manually written code). It includes defining MySQL tables, defining API interfaces, and writing specific logic code.On the other hand, the albumen acts as a bridge connecting the core business logic code to the web framework code (automatically generated, no manual writing needed). This includes the registration of route code generated from proto files, handler method function code, parameter validation code, error codes, Swagger documentation, and more.

Egg model profiling diagram for ⓷Web services created based on protobuf:

Image description

This is the egg model for web service code, and there are egg models for microservice (grpc) code, and grpc gateway service code described in sponge documentation.

Quick start

Installation sponge:

sponge can be installed on Windows, macOS, and Linux environments. Click here to view Installation Instructions.

After installing the sponge, start the UI service:

sponge run
Enter fullscreen mode Exit fullscreen mode

Visit http://localhost:24631 in your browser, generate code by manipulating it on the page.

Examples of use

Simple examples

No specific business logic code is included.

Complete project examples

Top comments (0)