This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func newStackLink() *StackLink { | |
return &StackLink{ | |
list: list.New(), | |
} | |
} | |
type StackLink struct { | |
list *list.List | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func TestUploadProgress(t *testing.T) { | |
progress := make(chan int, 1) | |
var src, upyunDest string | |
go func() { | |
var max, cur int | |
ticker := time.NewTicker(time.Second * 1) | |
defer ticker.Stop() | |
for { | |
select { | |
case <-ticker.C: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package transform | |
import ( | |
"fmt" | |
"sync" | |
"testing" | |
) | |
func TestSliceRest(t *testing.T) { | |
arr := make([]int, 0, 100) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type A struct { | |
B int | |
} | |
func TestParserResult_Accept(t *testing.T) { | |
a := &A{ | |
B: 1, | |
} | |
fmt.Printf("bf: %p\n", a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// C++ 提供了两种指针运算符,一种是地址运算符 &, 一种是间接寻址运算符 * | |
// 指针是一个包含了另一个变量地址的变量,你可以把一个包含了另一个变量地址的变量说成是 “指向” 另一个变量 | |
// 变量可以是任意的数据类型,包含对象、结构或指针。 | |
// | |
// 取地址运算符 & | |
// & 是一元运算符,返回操作数的内存地址。例如,如果 var 是一个整型变量,则 &var 是它的地址。 | |
// 该运算符与其他一元运算符有相同优先级,在运算时它是从右向左顺序进行的。 | |
// | |
// 你可以把 & 读作“取地址运算符”,这意味着,&var 读作 “var 的地址” | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 参考:https://www.cnblogs.com/pop-lar/p/5123014.html | |
// 从 foo 的输出可以看出: | |
// 声明为 thread_local 的本地变量在线程中是持续存在的,不同于普通临时变量的生命周期, | |
// 它具有 static 变量一样的初始化特征和生命周期,虽然他并没有被声明为 static。 | |
#include <thread> | |
thread_local int g_n = 1; | |
void f() { | |
g_n++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
// 函数声明 | |
void func(void); | |
static int count = 10; /* 全局变量 */ | |
int main() | |
{ | |
while(count--) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"fmt" | |
"time" | |
) | |
const shortDuration = time.Millisecond |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type InterfaceA interface { | |
A() | |
B() | |
C() | |
D() | |
} | |
type ImplA struct { | |
InterfaceA | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "time" | |
import "sync" | |
import "flag" | |
import "os" | |
import "log" | |
import "runtime" | |
import "runtime/pprof" | |
import "runtime/trace" |
NewerOlder