https://github.com/omalloc/kratos-console
https://github.com/omalloc/kratos-console
Last synced: 12 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/omalloc/kratos-console
- Owner: omalloc
- License: mit
- Created: 2023-08-08T13:41:20.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-03-19T12:31:28.000Z (11 months ago)
- Last Synced: 2025-07-05T09:44:59.827Z (7 months ago)
- Language: Go
- Size: 536 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Kratos Project Template
## Install Kratos
```
go install github.com/go-kratos/kratos/cmd/kratos/v2@latest
```
## Create a service
```
# Create a template project
kratos new server
cd server
# Add a proto template
kratos proto add api/server/server.proto
# Generate the proto code
kratos proto client api/server/server.proto
# Generate the source code of service by proto file
kratos proto server api/server/server.proto -t internal/service
go generate ./...
go build -o ./bin/ ./...
./bin/server -conf ./configs
```
## Generate other auxiliary files by Makefile
```
# Download and update dependencies
make init
# Generate API files (include: pb.go, http, grpc, validate, swagger) by proto file
make api
# Generate all files
make all
```
## Automated Initialization (wire)
```
# install wire
go get github.com/google/wire/cmd/wire
# generate wire
cd cmd/server
wire
```
## Docker
```bash
# build
docker build -t .
# run
docker run --rm -p 8000:8000 -p 9000:9000 -v :/data/conf
```
## Development
### with vscode debug
`.vscode/launch.json`
```jsonc
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch App",
"type": "go",
"request": "launch",
"mode": "auto",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/cmd/kratos-console/.",
"args": [
"--conf", "./configs/"
]
}
]
}
```