Singo: Simple Single Golang Web Service
go-crud has officially been renamed to Singo!
Build web services with Singo: use the simplest architecture to implement a practical framework that can serve massive numbers of users.
https://github.com/Gourouting/singo
Let's Build a G Site! Golang Full-Stack Programming Live Tutorial
Giligili, a Bilibili-like G site: https://github.com/Gourouting/giligili
Token-based mobile login example built with Singo: https://github.com/bydmm/singo-token-exmaple
This project uses a series of popular Golang components. You can use it as a foundation to quickly build RESTful web APIs.
This project integrates many components required for API development:
This project has already implemented some common code for reference and reuse:
/api/v1/user/register user registration endpoint./api/v1/user/login user login endpoint./api/v1/user/me user profile endpoint, which requires a session after login./api/v1/user/logout user logout endpoint, which requires a session after login.This project has also pre-created a series of folders for the following modules:
api folder is the controller layer of the MVC framework. It coordinates all parts to complete each task.model folder stores database models and database operation code.service folder handles more complex business logic. Modeling business logic can effectively improve business code quality, such as user registration, top-ups, and order placement.serializer folder stores common JSON models and converts database models from model into JSON objects required by the API.cache folder contains Redis cache-related code.auth folder contains permission control code.util folder contains common utility helpers.conf folder stores static configuration files. Translation-related configuration files are placed in locales.The project depends on the following environment variables at startup. You can also create a .env file in the project root to set environment variables more conveniently. This is recommended for development environments.
DB_USER="db_user" # MySQL user
DB_PASSWORD="db_password" # MySQL password
DB_HOST="127.0.0.1" # MySQL host
DB_PORT="3306" # MySQL port
DB_NAME="db_name" # MySQL database name
DB_CHARSET="utf8" # MySQL charset
DB_PARSE_TIME="True" # Parse MySQL time values
DB_LOC="Local" # MySQL time zone
REDIS_ADDR="127.0.0.1:6379" # Redis port and address
REDIS_PW="" # Redis connection password
REDIS_DB="" # Redis database, from 0 to 10
SESSION_SECRET="setOnProducation" # Session secret. It must be set and must not be leaked.
GIN_MODE="debug"
This project uses Go Mod to manage dependencies.
go mod init singo
export GOPROXY=http://mirrors.aliyun.com/goproxy/
go run main.go // automatically installs dependencies
go run main.go
After the project starts, it runs on port 3000. You can change this; see the Gin documentation for details.
[New] This project includes built-in API tests.
test directory.cp test/.env.example test/.env
test/.env to ensure that MySQL and Redis can be connected normally.-v to check whether the tests are running correctly.go test -v ./test
-v flag and check whether the tests pass.go test ./test
ok singo/test (cached)
$ claude mcp add singo \
-- python -m otcore.mcp_server <graph>