Skip to content

Instantly share code, notes, and snippets.

View haozibi's full-sized avatar
🍩
coding

haozibi haozibi

🍩
coding
View GitHub Profile
@haozibi
haozibi / grpc-gateway-demo.go
Created March 29, 2019 04:52
gRPC gateway 示例代码
package main
import (
"context"
"fmt"
"net"
"sync"
"github.com/fvbock/endless"
"github.com/gin-gonic/gin"
@haozibi
haozibi / goto.go
Last active April 15, 2019 06:11
golang goto 测试
package main
import (
"fmt"
"sync/atomic"
)
var b = 1
func main() {
@haozibi
haozibi / go-strings-bench.go
Created April 29, 2019 01:54
string 连接基准测试
package test
import (
"fmt"
"strconv"
"testing"
)
const (
str = "abc"
@haozibi
haozibi / singleflight-demo.go
Last active November 18, 2019 10:38
多个并发请求只让其中一个真正执行,其余阻塞等待到执行的那个请求完成,将结果传递给阻塞的其他请求达到防止雪崩的效果
package main
// by haozibi
// https://play.golang.org/p/QiQ4sBoVbCu
//
// 参考:
// https://segmentfault.com/a/1190000018464029
// https://github.com/golang/sync/tree/master/singleflight
// https://github.com/golang/groupcache/tree/master/singleflight
@haozibi
haozibi / golang-function-anonymous.go
Last active June 3, 2020 11:17
range 与 闭包的使用,Go词法作用域陷阱,捕获迭代变量 -- gopl 5.6.1
package main
import (
"fmt"
"sync"
)
var list = [...]int{1, 2, 3, 4, 5}
func main() {
@haozibi
haozibi / simple-goroutine-pool.go
Last active August 29, 2019 07:54
简陋的协程池
package main
import (
"fmt"
"sync"
)
// https://play.golang.org/p/jooMMwYID54
// 一个简单的协程池
// 关键问题是:range 读取 closed retCh 时才不会报错
package main
import "fmt"
func main() {
fmt.Println("hello")
}
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
npm config delete proxy