golang
已收录文章:14425篇
-
问题内容 我有这个简单的代码: import "fmt" type Foo struct { val int } func main() { var a = make([]*Foo, 1) a[0] = &Foo{0} var b = [3]Foo{Foo{1}, Foo{2}, Foo{3}} for _, e := range b { a = a119 收藏
-
问题内容 无论如何要string在 Go 中创建 null 终止? 我目前正在尝试的是a:="golang\0",但它显示编译错误: non-octal character in escape sequence: " 正确答案 规范:字符串文字: 引号383 收藏
-
问题内容 我有一个大小的字节数组,我在做md5.Sum(). data := []byte("testing") var pass string var b [16]byte b = md5.Sum(data) pass = string(b) 我得到错误: 无法将 b(类型 [16] 字节)转换为字符串类349 收藏
-
问题内容 我正在研究 Go,它看起来很有希望。我试图弄清楚如何获得 go 结构的大小,例如 type Coord3d struct { X, Y, Z int64 } 当然我知道它是 24 字节,但我想以编程方式知道它.. 你有什么想463 收藏
-
问题内容 我很难在 Go 中使用自定义错误类型。我读了这篇[关于错误的博客文章](http://blog.golang.org/error-handling-and- go) 所以我尝试了这个: 在我的 model.go 中,我定义了一个自定义错误: type201 收藏
-
问题内容 我正在尝试MarshalJSON使用界面自定义 的输出: func (m *RawMessage) MarshalJSON() ([]byte, error) 我按照那个教程:[http ://choly.ca/post/go-json-marshalling/](http://choly.ca/post/go- json-marshalling/) 我的目500 收藏