gin-systray-starter
Starter code for Go application with Gin, System Tray, Gorm, Air, Swagger, JWT
- systray, https://github.com/getlantern/systray
- gin, https://github.com/gin-gonic/gin
- air, https://github.com/cosmtrek/air
- gorm, https://gorm.io/
- swagger, https://github.com/swaggo/gin-swagger
- jwt, https://github.com/golang-jwt/jwt
System
- Windows 10
- Go 1.17
- Npm v8
Setup
# install air cli
curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
# install swag cli
go install github.com/swaggo/swag/cmd/swag@latest
# install go dependencies
go mod tidy
Npm Scripts
Run only the http server with air hot reload,
npm run serve
Re-generate swagger configuration (do this when APIs changed)
npm run swag
Build and run the project (without flags)
npm run build:run
Build the project (with flags, -tags=jsoniter -ldflags "-H=windowsgui"
)
npm run build
Structure
- /database
init database connection
- /models
map database structure && provide CRUD for each table
- /models
- /swagger
auto-generated swagger configuration
- /server
init http server
- /controllers
actions for each API (request -> services -> response)
- /middlewares
hooks/filters/interceptors
- auth.go
jwt declaration and authentication gateway
- auth.go
- /routers
groups of APIs
- /services
services (involve multiple models) to be used in actions
- api.go
swag General API annotations with a set of API routers/groups
- /controllers
- /tray
init system tray
- /icons
icons for the tray and menu items
- /locales
language files for the tray
- /icons
- /air
air configuration and temporary output files
- .air.toml
air cli config
- .air.toml
- main.go
app entry