web

command module
v0.0.0-...-d728bd2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 1, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

README

go-demo web

Build & Run

go mod download

go build

./web

Systemd

可执行目录结构:

/usr/local/demo-web
├── web
└── web.yaml

Systemd 脚本:

cp init/demo-web.service /usr/lib/systemd/system/

systemctl daemon-reload
systemctl start demo-web

Air 热加载

go install github.com/cosmtrek/air@latest

air init

air

Swagger

安装本地的 swagger 程序:

go install github.com/swaggo/swag/cmd/swag

项目已经集成 gin-swagger, 在项目目录下执行:

swag init -g internal/web/swagger.go -o "docs"

可修改 Air 参数实现热加载自动生成 Swagger:

[build]
  cmd = "swag init -g internal/web/swagger.go -o docs && go build -o ./tmp/main ."

访问 Swagger: http://localhost:8080/swagger/index.html

pprof

go tool pprof http://localhost:8080/debug/pprof/heap
go tool pprof http://localhost:8080/debug/pprof/profile
go tool pprof http://localhost:8080/debug/pprof/block

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package docs GENERATED BY SWAG; DO NOT EDIT This file was generated by swaggo/swag
Package docs GENERATED BY SWAG; DO NOT EDIT This file was generated by swaggo/swag
internal
pkg
web

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL