go web skeleton
1.0.0
완전한 Golang 웹 응용 프로그램 골격.
中文说明
포함
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 :
구성 레지스터 센터 :
Dockerfile : Alpine을 기반으로 한 프로덕션 환경을위한 Docker Image Build Script, 약 30m의 추정 크기의 프로젝트 이미지 구축makefile : 문서화를 신속하게 생성하고 이미지를 빌드하는 데 도움이되는 일부 빠른 제작 명령이 구축되었습니다. 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는 Parsing Field 설명 필드의 의견에서 정보입니다.
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