Go
文章平均质量分 55
HayPinF
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Go读写锁设计(转载自飞雪无情)
https://mp.weixin.qq.com/s/74T2CAWEu2R-ZYM1J7xekA转载 2021-01-21 10:20:25 · 185 阅读 · 0 评论 -
Golang的终端循环输入io.Copy(*,os.Stdin)
1、io.Copy(dst Writer, src Reader)(written int64, err error)haypin@MBP /usr/local/go/src/os go doc io.Copypackage io // import "io"func Copy(dst Writer, src Reader) (written int64, err error) Copy copies from src to dst until either EOF is rea原创 2021-01-15 22:21:16 · 1700 阅读 · 0 评论 -
Golang切片传引用的注释事项,有向图数据结构的生成,深度优先与广度优先遍历
1、Golang切片Go数组与C++数组一样,理论上,在定义时就要使用常数字面值定义数组大小,然后Go将对数组初始化为元素类型的零值,C++则不会进行初始化,只是返回Go:var arr [3]int //自动初始化为{0,0,0}arr = [3]int{1, 2, 3} //C++:静态数组:规范的用法是在数组定义时使用常数字面值定义数组大小,从而使静态数组在编译期间就能确定要分配的栈内存大小。但有的编译器,比如darwin的clang++,也是可以用变量指定数组大小的。...原创 2021-01-03 16:05:55 · 394 阅读 · 0 评论 -
最长公共子串 二维数组 Go实现
参考:https://blog.youkuaiyun.com/dongyanwen6036/article/details/87914940//CommonSubstr 寻找两个字符串间的最大相同子串func CommonSubstr(A string, B string) string { //构造BxA的二维数组C,每个元素C[i][j]包含两个信息:1、该元素对应的B[i]与A[j]两个字符是否相同 //2、 如果B[i]与A[j]相同,且各倒退一个字符B[i-1]A[j-1]也相同,则与前面.转载 2021-01-01 14:55:46 · 366 阅读 · 0 评论 -
leetcode 174地下城游戏 动态规划解法的Go语言实现 原创
https://mp.weixin.qq.com/s/MydL7eyzdfJc6jYZNwFWWw正好在学Go语言,斗胆用Go答题,写了很长://20201231FHP:动态规划魔塔问题package mainimport "fmt"func init() {}func main() { var nRow int = 3 var nCol int = 3 var dp = make([][][]int, nRow, nRow) for i := 0; i < nRow原创 2020-12-31 19:53:53 · 210 阅读 · 0 评论 -
实验出Golang无类型整数常量在mac上提供至少256bit至多512bit的存储空间
《The Go Programming Launage》(Go语言圣经)无类型常量:我的理解:Go的基础类型有:整数:int8、int16、int32、int64,浮点数:float32、float64,复数:complex64、complex128,字符:byte(1字节)、rune(4字节);当给出形如"const EiB = 1<<60"的常量声明,即常量声明没有显式给出类型,则:1、当常量表达式的值能够使用内置的最大类型(比如int64)存储时,Go编译器会使用该最大类型存储常量转载 2020-12-23 23:24:06 · 492 阅读 · 0 评论 -
Golang返回变量占用内存的大小的方法与unsafe.Sizeof(variable)
转载:https://ask.youkuaiyun.com/questions/1010779如果传递一个未初始化的变量,unsafe.SizeOf()与reflect.Type.Size()将只返回传递的变量的类型的大小,并不递归地遍历数据结构并增加所指向变量的大小。切片是一个相对简单的结构体struct:reflect.SliceHeader,因为我们知道切片是引用一个备份的数组(或字符串——byte数组),我们可以简单地手动计算它的大小:sliceint := make([]int32, 1000)转载 2020-12-22 23:57:48 · 4228 阅读 · 1 评论 -
Golang的rune数据类型,Unicode字符编码与UTF-8字节码
转载:https://www.jianshu.com/p/4fbf529926carune类型:// rune is an alias for int32 and is equivalent to int32 in all ways. It is// used, by convention, to distinguish character values from integer values.//int32的别名,几乎在所有方面等同于int32//它用来区分字符值和整数值type r转载 2020-12-21 11:30:27 · 2314 阅读 · 0 评论 -
Go允许函数返回局部变量,依托Go编译器对此行为进行的“逃逸分析“,Go语言GC
转载:https://blog.youkuaiyun.com/li_101357/article/details/80209413How do I know whether a variable is allocated on the heap or the stack?From a correctness standpoint, you don't need to know. Each variable in Go exists as long as there are references to it.转载 2020-12-19 21:43:34 · 162 阅读 · 2 评论 -
Go编译报错go build: build output “dirmain“ already exists and is a directory
比如当前目录是$GOPATH/src/GO1209,当前目录有个文件夹dirmain是一个包,如果指定包的文件夹进行编译,会报错输出文件dirmain在当前目录已经存在并且是个目录:VMCatalina:src haypin$ tree Go1209Go1209├── dirmain│ ├── go.mod│ ├── gomain.go│ ├── gomain2.go│ └── gomain3.goVMCatalina:src haypin$VMCatalina:Go1原创 2020-12-09 17:04:05 · 1980 阅读 · 0 评论 -
go get时xx cannot download,xx is a GOROOT, not a GOPATH,以及cannot find packag “.“in:$GOPATH/src/vendor
转载自https://studygolang.com/articles/27122https://stackoverflow.com/questions/42809990/go-get-cannot-download-home-azhukov-go-is-a-goroot-not-a-gopath"This error is caused by thegotool detecting a Go installation in your GOPATH. It's not telling you t..转载 2020-12-05 21:52:28 · 453 阅读 · 0 评论 -
VScode Go 配置代理
mac VScode上使用 Go Team at Google谷歌官方的Go扩展这个扩展下载包时使用"/usr/local/go/bin/go get -v github.com/mdempsky/gocode"命令,使用TCP通话会超时Tools environment: GOPATH=/Users/haypin/goInstalling 7 tools at /Users/haypin/go/bin in module mode.gocodegopkgsgo-outlinegoc原创 2020-12-03 21:57:36 · 2008 阅读 · 2 评论
分享