Kata should be called "routine" in Chinese. The secret of practicing martial arts is to master various routines.
First, you must learn from the strengths of hundreds of schools and be familiar with the routines of various schools in the world. Only then can you integrate them and achieve the state of no moves being better than moves.
Dave Thomas - the author of "The Pragmatic Programmer", proposed the idea of Code Kata. Dave also collected a small practice project on his website (http://codekata.com/).
As a professional programmer, I hope to practice some routines that can be often used in work, such as some small routines for file modification, image cutting, and network sending and receiving, so I will organize and collect some routines here.
- cron-service.go: demostration of how to implement cron job
- encoding_tool: demostrate how to implement encoding command line tool by cobra library
- ds_web_console: demostrate how to call deep seek api and provide a web console by gin library
- ata-auth: demostrate how to implement a simple auth system by casbin
- list_files.go: demostrate how to list files in a directory
- links.go: demostrate how to use http client to get links from a web page
- llm-agent-go: demostrate how to implement a simple llm agent by gin and vue.js
- prompt_service: demostrate how to implement a simple prompt management service by gin and gorm with sqlite db
- prompt_service_v2: add login and metrics endpoint for prompt management service
- service-monitor: demostrate how to monitor a backend service with prometheus exportor
- simple-ai-agent: demostrate how to use function calling and tools of openai
- unix_socket: demostrate how to use unix socket to communicate with backend service
go build xxx.go
go run xxx.go
go list, go get, go mod xxx
go mod init my_project
go mod tidy
go fmt, gofmt
dlv debug main.go
go doc, godoc
go install github.com/swaggo/swag/cmd/swag@latest
swag init
go test
go vet, golangci-lint
e.g.
brew install golangci-lint
golangci-lint run ./...
go tool pprof, go tool trace
go tool pprof http://localhost:6060/debug/pprof/profile
go run main.go
go tool trace trace.out
go tool fix
go bug
- install go extensions and delve
- configuration of go debug in vscode
{
// 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": "Debug file",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${file}"
},
{
"name": "Launch Package",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}"
}
]
}