![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
go
文章平均质量分 63
sinat_15355869
这个作者很懒,什么都没留下…
展开
-
golang tollbooth 中间件 & 压测工具 vegeta
参考:1、[译] Go 中基于 IP 地址的 HTTP 限流2、Tollbooth - Fasthttp integration layer3、didip/tollbooth Simple middleware to rate-limit HTTP requests4、valyala / fasthttp Fast HTTP package for Go5、uber-go / ratelimit6、ulule / limiter-examples - 法国众筹公司🤦🏻♀️7、t原创 2022-04-16 17:01:20 · 767 阅读 · 0 评论 -
go - by example
递归package mainimport ( "fmt" "math")// 递归func fact(n int) int { if n == 0{ return 1 } return n * fact(n-1)}func main(){ fmt.Println(fact(3))}指针//指针func zeroval(ival int) { ival = 0}func zeroptr(iptr *int){ *iptr =...原创 2020-09-11 22:31:26 · 107 阅读 · 0 评论 -
learning go - by example
// array package mainimport "fmt"func main(){ var a [5]int fmt.Println("emp:", a) a[4] = 100 fmt.Println("set:", a) fmt.Println("get:", a[4]) fmt.Println("len:", len(a)) b := [5]int{1, 2, 3, 4, 5} fmt.Println("cdl: ", b)...原创 2020-09-11 11:20:18 · 206 阅读 · 0 评论 -
go-可复用模块(包管理)
原创 2020-05-29 12:31:05 · 184 阅读 · 0 评论 -
go-panic和recover
package panic_revocerimport ( "errors" "fmt" "testing")func TestPanicVxExit(t *testing.T){ defer func(){ fmt.Println("Finally") }() fmt.Println("Start") panic(errors.New("Something wrong!")) // 输出调用栈的信息 //os.Exit(-1)}packag...原创 2020-05-29 11:22:55 · 102 阅读 · 0 评论 -
go-错误机制
package errorimport ( "errors" "fmt" "testing")var LessThanTwoError = errors.New("n should be not less than 2")var LargerThanHoundredEooro = errors.New("n should be not larger than 100")func GetFibnacci(n int) ([]int, error) { //if n <...原创 2020-05-29 11:06:03 · 149 阅读 · 0 评论 -
go-多态和接口
package polymorphicimport ( "fmt" "testing")type Code string // type定义新的类型, 别名type Programmer interface { //type定义接口 WriteHelloWorld() Code}type GoProgrammer struct {}type JavaProgrammer struct {}func (p *GoProgrammer) WriteHelloW...原创 2020-05-29 09:20:54 · 134 阅读 · 0 评论 -
go-扩展与复用
package extensionimport ( "fmt" "testing")type Pet struct{}func (p *Pet) Speak() { fmt.Print("...")}func (p *Pet) SpeakTo(host string) { p.Speak() fmt.Println(" ", host)}//type Dog struct {// p *Pet//}//func (d *Dog) Speak() {// .原创 2020-05-28 20:50:06 · 187 阅读 · 0 评论 -
go-接口
package _interfaceimport "testing"// 定义接口type Programmer interface { WriteHelloWorld() string}// 定义接口的实现,这里暂时不定义成员了type GoProgrammer struct{}// 定义接口的方法, duck typefunc(g *GoProgrammer) WriteHelloWorld( ) string{ return "fmt.Println(\"Hell...原创 2020-05-28 20:32:11 · 94 阅读 · 0 评论 -
go-行为定义和实现
package objimport ( "fmt" "testing" "unsafe")// 数据的定义type Employee struct{ Id string Name string Age int}func TestCreateEmployeeObj(t *testing.T){ e := Employee{"0", "Bob", 20} e1 := Employee{Name:"Mike", Age:18} e2 := new(Employee) e.原创 2020-05-28 20:16:42 · 194 阅读 · 0 评论