Advanced Search
Search Results
6 total results found
Wire
Automated Initialization in Go. https://github.com/google/wire
Go Modules
Upgrade Hashgo get github.com/user/repo@838316b649e9e87e52e0ef72ca4da8e266c7994d Branchgo get github.com/user/repo@feature-foo
Architecture
Web ├── cmd/ │ └── main.go ├── internal/ │ ├── controller/ │ │ └── user_controller.go │ ├── service/ │ │ └── user_service.go │ ├── repository/ │ │ └── user_repository.go │ └── model/ │ └── user.go ├── pkg/ │ └── common/ └── confi...
omitempty
默认行为 在使用 protoc 3 时,默认会为所有标量字段(包括字符串)添加 omitempty 标签。这是 protobuf 3 的一个默认行为。要解决这个问题,有几种方式: gogoproto 例子1 Inputmessage Config { int64 id = 1; string name = 2 [(gogoproto.jsontag) = "name"]; string desc = 3 [(gogoproto.jsontag) = "desc"]; Role role = 5 ...
Batch Send With Timeout
idleDuration := 10 * time.Second idleDelay := time.NewTimer(idleDuration) for { idleDelay.Reset(idleDuration) msgQueue := make([]model.MinIOEvent, 0, BatchSize) var needToSend bool for !needToSend { select { case msg := <-k.ms...
GORM Update
会忽略零值字段(默认值) type User struct { Name string Age int } db.Model(&user).Updates(User{Name: "Tom", Age: 0}) 这条语句中,Age: 0 会被忽略,因为 GORM 默认只更新非零值字段。 Solutions Model.Update(column, value) db.Model(&user).Update("age", 0) // 会把 age 更新为 0 使用 Map db.Model(&user...