go web skeleton
1.0.0
完全なGolang Webアプリケーションスケルトン。
中文说明
含まれる:
gookit/slog構成を使用しますgo modを使用して、管理依存関係をインストールしますgithubプロジェクト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:
Config Register Center:
Dockerfile :Alpineに基づいた生産環境向けのDocker画像ビルドスクリプトは、推定サイズ約30 mのプロジェクト画像を構築しますmakefile :ドキュメントをすばやく生成して画像を作成するのに役立つクイックオンメイクコマンドが構築されました。 go-web-skeletonディレクトリをプロジェクト名に変更します。github.com/inhere/go-web-skeleton 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 ./...mit