golang
已收录文章:14180篇
-
问题内容 如何在 Go 中实现一个抽象类?由于 Go 不允许我们在接口中有字段,这将是一个无状态对象。那么,换句话说,是否有可能在 Go 中为方法提供某种默认实现? 考虑一个例子: type D435 收藏
-
问题内容 我有一个打算用数据库记录填充的结构,其中一个日期时间列可以为空: type Reminder struct { Id int CreatedAt time.Time RemindedAt *time.Time SenderId int ReceiverId int } 由126 收藏
-
问题内容 I'm trying to detect sending failures by inspecting the error returned by golang TCPConn.Write, but it's nil. I also tried using TCPConn.SetWriteDeadline without success. That's how things happen: the server starts a client connects th168 收藏
-
问题内容 我正在尝试select在循环中使用 a 来接收消息或超时信号。如果收到超时信号,循环应该中止: package main import ("fmt"; "time") func main() { done := time.After(1*time.Millisecond)454 收藏
-
问题内容 在 go 中,是否可以以某种方式动态转换变量? 例如,如果一个简单的演员表是: var intAge = interfaceAge.(int) 如果我事先不知道年龄是一个整数怎么办?一个简单的写法是 var x = getT198 收藏
-
问题内容 我需要在字节缓冲区中提取各种字段。我想出了这个解决方案: func (fs *FileSystem) readSB() { // fs.f is a *os.File buf := make([]byte, 1024) fs.f.ReadAt(buf, 1024) // Offset: type var p *byt392 收藏