Skip to content

Instantly share code, notes, and snippets.

View weilinux's full-sized avatar
🎯
Focusing

HORSE weilinux

🎯
Focusing
View GitHub Profile
@weilinux
weilinux / docker-compose.yaml
Created August 17, 2025 06:14
docker-compose 部署GO应用
services:
order-service:
build:
context: ./
dockerfile: ./build/package/Dockerfile
ports:
- "8080:8080"
- "9090:9090"
depends_on:
db:
@weilinux
weilinux / go framework.md
Created May 14, 2025 11:00
go framewok benchmark of concurrency

image

@weilinux
weilinux / golang代码阅读角度.md
Last active May 11, 2025 14:55
golang代码阅读角度

Understanding Go's backend architecture requires a systematic approach that focuses on patterns rather than individual lines of code. Let's break this down into clear, manageable concepts.

Core Architectural Patterns

  1. Layered Architecture - Separate concerns into distinct layers
  • Each layer communicates through well-defined interfaces
  • Enables independent evolution of components
  1. Interface-Oriented Design - Define contracts through interfaces 1:1
@weilinux
weilinux / RBAC_demo.md
Last active May 5, 2025 15:06
RBAC-demo

权限模型 https://github.com/chenyongze/go-api-admin

image-20250505111206454

CREATE TABLE `dt_uc_admin` (
  `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
  `login_name` varchar(20) NOT NULL DEFAULT '' COMMENT '用户名',
  `real_name` varchar(32) NOT NULL DEFAULT '0' COMMENT '真实姓名',
@weilinux
weilinux / go_struct_define.md
Created April 28, 2025 10:12
go结构体何时定义

在Go中,定义结构体(struct)是一个重要的设计决策。让我们通过实际场景来理解什么时候应该定义一个结构体:

使用结构体封装相关数据

type Photo struct {
    ID        string
    Filename  string
    Metadata  map[string]interface{}
    CreatedAt time.Time
}
@weilinux
weilinux / go_method_receiver.md
Last active April 28, 2025 09:57
go方法接收器的选择问题

在Go语言中,方法接收器(receiver)有两种形式:值接收器和指针接收器。让我们详细比较这两种方式:

特性 值接收器(h Handler) 指针接收器(h *Handler)
修改能力 只能读取,不能修改原值 2:3 可以修改原值 3:5
内存使用 创建副本,消耗更多内存 直接操作原始数据,更节省内存
方法调用 可用于值和指针接收者 同样可用于值和指针接收者 0:1
适用场景 只读操作、计算等不需要修改状态的场景 需要修改结构体字段或处理大型数据结构时

让我们通过一个图表来直观地理解它们的区别:

@weilinux
weilinux / go_vscode_goland_LiteIDE_VIM_Emacs配置.go
Last active April 28, 2025 08:50
go vscode goland IDE配置
https://github.com/astaxie/build-web-application-with-golang/blob/c294b087b96d99d2593ad8f470151af5354bb57f/zh/01.4.md?plain=1#L1
@weilinux
weilinux / project_debt_.go
Created April 27, 2025 15:27
go 技术债务
go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
PS D:\GoLandProjects\go\src\level_old002_concept\planet> gocyclo -top 10 .
150 tool GetAxleOne toro\tool\appUtil.go:382:1
70 service TpService toro\service\tpService.go:223:1
64 aep querySettingData internal\aep\aepexchange.go:32:1
56 service brakingMessageBraking toro\service\tpService.go:629:1
56 aep ParseMessageCMD internal\aep\aep.go:877:1
56 aep ParseMessage internal\aep\aep.go:161:1
42 tool GetModelIdLocation toro\tool\appUtil.go:103:1
@weilinux
weilinux / GORM_表关系_douyin_project.go
Last active April 25, 2025 15:45
gorm_表关系_demo
https://github.com/acking-you/byte_douyin_project.git
type UserInfo struct {
Id int64 `json:"id" gorm:"id,omitempty"`
Name string `json:"name" gorm:"name,omitempty"`
FollowCount int64 `json:"follow_count" gorm:"follow_count,omitempty"`
FollowerCount int64 `json:"follower_count" gorm:"follower_count,omitempty"`
IsFollow bool `json:"is_follow" gorm:"is_follow,omitempty"`
User *UserLogin `json:"-"` //用户与账号密码之间的一对一
Videos []*Video `json:"-"` //用户与投稿视频的一对多
@weilinux
weilinux / storage_Layer_demo.go
Last active April 24, 2025 04:02
storage 层
---
main.go
func seedAccount(store Storage, fname, lname, pw string) *Account {
}
func seedAccounts(s Storage) {
seedAccount(s, "anthony", "GG", "hunter88888")
}
func main() {
seed := flag.Bool("seed", false, "seed the db")