go web skeleton
1.0.0
โครงกระดูกแอปพลิเคชันเว็บ Golang ที่สมบูรณ์
中文说明
ประกอบด้วย:
gookit/slog การกำหนดค่าที่ใช้go mod เพื่อติดตั้งการอ้างอิงการจัดการ GitHub Project https://github.com/inhere/go-web-skeleton
api/ API interface application handlers
|- controller/
|- middleware/
|_ routes.go
app/ Common directory (public methods, application initialization, public components, etc.)
cmd/ CLI command line application commands
|_ cliapp/ command line application entry file (main)
config/ Application configuration directory (basic configuration plus various environment configurations)
model/ Data and logic code directory
|- form/ Request form structure data definition, form validation configuration
|- logic/ Logic processing
|- mongo/ MongoDB data collection model definition
|- mysql/ MySQL data form model definition
|_ rds/ Redis data model definition
resource/ Non-code resources used by some projects (language files, view template files, etc.)
runtime/ Temporary file directory (file cache, log files, etc.)
static/ Static resource directory (js, css, etc.)
main.go Web application entry file
Dockerfile Dockerfile
Makefile Has written some common shortcut commands to help package, build docker, generate documentation, run tests, etc.
...
เรนเดอร์โดย
tree -d 2 ./
ใช้แพ็คเกจ GO ที่ใช้แล้ว
ให้บริการและการกำหนดเส้นทาง HTTP
อื่น :
แอปพลิเคชันบรรทัดคำสั่ง
การจัดการการกำหนดค่า
mysql:
MongoDB:
Redis:
ขอการตรวจสอบข้อมูล
ห้องสมุดการทำให้เป็นอนุกรมประสิทธิภาพสูง
JSON:
กำหนดค่าศูนย์ทะเบียน:
Dockerfile : Docker Image Build Script สำหรับสภาพแวดล้อมการผลิตตามอัลไพน์สร้างภาพโครงการที่มีขนาดประมาณ 30 เมตรmakefile : คำสั่ง Make อย่างรวดเร็วบางอย่างได้ถูกสร้างขึ้นเพื่อช่วยสร้างเอกสารและสร้างภาพอย่างรวดเร็ว go-web-skeleton เป็นชื่อโครงการของคุณgithub.com/inhere/go-web-skeleton ด้วยชื่อโครงการของคุณ (สำหรับไฟล์ GO)go-web-skeleton ทั้งหมดด้วยชื่อโครงการของคุณ (ส่วนใหญ่ DockerFile, MakeFile)go mod tidy เพื่อติดตั้งไลบรารีที่ขึ้นอยู่กับgo run main.gogo run ./cmd/appinitการติดตั้ง:
go get -u github.com/swaggo/swag/cmd/swagโปรดตรวจสอบเอกสารและตัวอย่างของ
swaggo/swag
สร้างขึ้นในไดเรกทอรีที่ระบุ:
swag init -o static
# This file will be generated at the same time. It can be deleted if it is not needed.
rm static/docs.goสังเกต:
swaggo/swagเป็นข้อมูลคำอธิบายฟิลด์การแยกวิเคราะห์จากความคิดเห็นของสนาม
type SomeModel struct {
// the name description
Name string `json:"name" example:"tom"`
} Go test
// output coverage
Go test -covergofmt -s -l ./
go fmt ./...หมายเหตุ: คุณต้องติดตั้ง
GoLintก่อน
golint ./...มิกซ์