04 2021 档案
摘要:https://studygolang.com/topics/10399 var a = []int{1,2,3} fmt.Printf("%p\n", &a) b :=a fmt.Printf("%p\n",&b) // 问题1、为什么b的地址跟a不同,他们不是共享底层数组吗? b = appen
阅读全文
摘要:https://www.cnblogs.com/chenwenbiao/archive/2011/08/01/2123905.html demo.php <?php $fp = fopen("file_lock.txt", "w"); //加锁 if (flock($fp, LOCK_EX)) {
阅读全文
摘要:https://gavv.github.io/articles/file-locks/ File locking in Linux 29 Jul 2016 linux posix ipc Table of contents Introduction Advisory locking Common f
阅读全文
摘要:package main import ( "log" "os" ) var size = int64(1024 ) func main() { f, err := os.Create("foobar1.bin") if err != nil { log.Fatal(err) } defer f.C
阅读全文
摘要:1、使用mmap需要注意的一个关键点是,mmap映射区域大小必须是物理页大小(page_size)的整倍数(32位系统中通常是4k字节)。原因是,内存的最小粒度是页,而进程虚拟地址空间和内存的映射也是以页为单位。为了匹配内存的操作,mmap从磁盘到虚拟地址空间的映射也必须是页。 再啰嗦几句: lin
阅读全文
摘要:15 2 Is there anyway to create null terminated string in Go? What I'm currently trying is a:="golang\0" but it is showing compilation error: non-octal
阅读全文
摘要:原文: https://studygolang.com/articles/2271 package main import ( "fmt" "strings" "log" ) func main() { reader := strings.NewReader("Go语言学习园地") reader.S
阅读全文
摘要:原文:https://blog.csdn.net/cywosp/article/details/8767327 结合 https://github.com/boltdb/bolt.git boltdb源码看,就能发现它里面就用了fdatasync函数,来确保修改确实成功写入了磁盘。 传统的UNIX实
阅读全文
摘要:问题: I'm not sure what I'm missing but I get a deadlock error. I'm using a buffered channel that I range over after all go routines complete. The chann
阅读全文
摘要:原文:https://www.oldboyedu.com/zuixin_wenzhang/index/id/486.html package main import ( "sync" "log" ) func main() { var wg sync.WaitGroup for i := 0; i
阅读全文
摘要:原文:https://medium.com/@kdnotes/sort-sort-interface-in-golang-1d263d96956d package main import ( "fmt" "sort" //"unicode/utf8" ) type P struct { name s
阅读全文
摘要:转, 原文:https://www.jianshu.com/p/29ac532e7c96 type SizeOfE struct { A byte // 1 C byte // 1 B int64 // 8 } 内存分布图: package main import ( "log" "unsafe"
阅读全文
摘要:原文: https://blog.csdn.net/yzf279533105/article/details/97143100 package main import ( "fmt" "unsafe" "log" ) type Person struct { name string age int
阅读全文
摘要:Alignof返回的对齐数是结构体中最大元素所占的内存数,不超过8, 参考:https://studygolang.com/articles/21827 unsafe.Sizeof 和 unsafe.Offsetof 的理解 package main import ( "fmt" "unsafe"
阅读全文
摘要:原文: https://studygolang.com/articles/21827 以下讲解均在64位系统下进行 基础类型大小 typesize/bytes bool 1 intN, uintN, floatN, complexN N/8 int, uint, uintptr 1 *T 1 str
阅读全文
摘要:https://www.digitalocean.com/community/tutorials/how-to-do-math-in-go-with-operators#:~:text=If%20we're%20dividing%20integers,than%20or%20equal%20to%2
阅读全文
摘要:转,原文:https://www.cnblogs.com/lianzhilei/p/6025267.html Nginx查看并发连接 通过界面查看 通过界面查看通过web界面查看时Nginx需要开启status模块,也就是安装Nginx时加上 --with-http_stub_status_modu
阅读全文
摘要:为什么会报错呢? 为什么用append()却不会报错?? 用s[i] = i+3 这种方法会报错 package main import ( "log" ) func main() { s := make([]int, 2, 3) for i:= 0; i< 10; i++ { //s = appe
阅读全文
摘要:https://www.jianshu.com/p/964b887da04c package main import ( "fmt" "os" "syscall" ) const maxMapSize = 0x8000000000 const maxMmapStep = 1 << 30 // 1GB
阅读全文
摘要:数据库事务的ACID特性理解: 转,原文: https://www.jianshu.com/p/fc8a654f2205 事务具有4个特征,分别是原子性、一致性、隔离性和持久性,简称事务的ACID特性; 一、原子性(atomicity) 一个事务要么全部提交成功,要么全部失败回滚,不能只执行其中的一
阅读全文
摘要:https://www.cnblogs.com/liujie-php/p/10716811.html https://www.cnblogs.com/onedime/archive/2012/11/20/2779707.html 学了这么多年C语言、C++、VC、MFC,但却从来没有认真研究过各种数
阅读全文
摘要:转,原文: https://www.cnblogs.com/liujie-php/p/10716811.html 主机字节序 主机字节序模式有两种,大端数据模式和小端数据模式,在网络编程中应注意这两者的区别,以保证数据处理的正确性;例如网络的数据是以大端数据模式进行交互,而我们的主机大多数以小端模式
阅读全文
摘要://通过将float64类型指针转化为uint64类型指针,我们可以查看一个浮点数变量的位模式。 func Float64bits(f float64) uint64 { fmt.Println(reflect.TypeOf(unsafe.Pointer(&f))) //unsafe.Pointer
阅读全文
摘要:package main import ( "log" ) type meta struct { name string age int } func (m *meta) copy(dest *meta) { *dest = *m } func main() { a := meta{name:"aa
阅读全文
摘要:稍微手写了几个类似table 的布局, 用div 来实现类table的布局。感觉还是没办法做到table 的效果。最终,还是使用table 来实现了。 可能用div 也能实现table的布局效果,但是还需要在摸索一下,目前先用table来实现。 一个table 中 可以有多个tbody. 参考: h
阅读全文