000、GO之特别语法糖
    
            
摘要:01、使用...打散参数 1 package main 2 3 import ( 4 "fmt" 5 ) 6 7 func main() { 8 s := []byte("hello ")//强转 9 s = append(s, "world"...)//向byte切片追加,...表示将字符串打散成
        
阅读全文
 
            
                posted @ 
2020-05-04 11:30 
TBBS
        
阅读(141) 
         
        推荐(0)     
             
         
            
            
    000、GO之深刻理解拷贝
    
            
摘要:01、值类型和引用类型 GO只有slice、map、chan 3种引用类型,其它都是值类型 02、slice引用拷贝 1 package main 2 3 import ( 4 "fmt" 5 ) 6 7 func appendSlice(s []int) { 8 s[0] = 10//成功修改ma
        
阅读全文
 
            
                posted @ 
2020-05-02 22:01 
TBBS
        
阅读(170) 
         
        推荐(0)     
             
         
            
            
    000、常见算法解析
    
            
摘要:01、按照内存对齐,重新计算结构体长度 1 const ( 2 maxAlign = 8 //按照8个byte进行内存对齐 3 hchanSize = unsafe.Sizeof(hchan{}) + uintptr(-int(unsafe.Sizeof(hchan{}))&(maxAlign-1)
        
阅读全文
 
            
                posted @ 
2020-05-02 21:07 
TBBS
        
阅读(134) 
         
        推荐(0)     
             
         
            
            
    003、GO之并发
    
            
摘要:01、使用chan控制程序结束 package main import "fmt" func main() { c := make(chan bool) go func() { fmt.Println("hello") c <- true }() <-c } 02、遍历chan 1 package 
        
阅读全文
 
            
                posted @ 
2020-05-02 11:40 
TBBS
        
阅读(153) 
         
        推荐(0)     
             
         
            
            
    002、GO之反射
    
            
摘要:01、反射字段和方法 1 package main 2 3 import ( 4 "fmt" 5 "reflect" 6 ) 7 8 type Name struct { 9 name string 10 age int 11 } 12 13 func (n Name) Print() { 14 f
        
阅读全文
 
            
                posted @ 
2020-05-02 09:21 
TBBS
        
阅读(190) 
         
        推荐(0)     
             
         
            
            
    001、GO之指针转换
    
            
摘要:01、Pointer类型 unsafe包下,有定义type Pointer *ArbitraryType(任意类型指针),可绕过GO的类型限制,type ArbitraryType int 任何类型的指针值都可以转换为Pointer。 Pointer可以转换为任何类型的指针值。 uintptr可以转
        
阅读全文
 
            
                posted @ 
2020-04-28 20:56 
TBBS
        
阅读(1338) 
         
        推荐(0)