摘要:
变量 var 变量名 类型 = 表达式 var name string = "Q1mi" var age int = 18 #匿名变量 func foo() (int, string) { return 10, "Q1mi" } func main() { x, _ := foo() _, y := 阅读全文
posted @ 2021-01-22 17:24
pebblecome
阅读(53)
评论(0)
推荐(0)
摘要:
目录列表 安装gin框架 go get github.com/gin-gonic/gin 路由包 package routers import ( "github.com/gin-gonic/gin" "lesson26/bubble/controller" ) func SetupRouter() 阅读全文
posted @ 2021-01-22 17:02
pebblecome
阅读(79)
评论(0)
推荐(0)
摘要:
客户端client package main import ( "bufio" "fmt" "net" "os" "strings" ) //客户端 func main() { conn,err := net.Dial("tcp","127.0.0.1:20000") if err !=nil{ f 阅读全文
posted @ 2021-01-22 16:52
pebblecome
阅读(62)
评论(0)
推荐(0)
摘要:
安装 go get github.com/go-sql-driver/mysql 代码示例 package main import ( "context" "database/sql" "fmt" _ "github.com/go-sql-driver/mysql" "log" "strconv" 阅读全文
posted @ 2021-01-22 13:05
pebblecome
阅读(163)
评论(0)
推荐(0)
摘要:
代码示例 package main import ( "fmt" "log" "net/http" "time" ) func setCookie(w http.ResponseWriter,r *http.Request) { expiration := time.Now().Add(time.H 阅读全文
posted @ 2021-01-22 12:58
pebblecome
阅读(111)
评论(0)
推荐(0)
摘要:
代码示例 package main import ( "bufio" "fmt" "os" "strings" "sync" ) //使用锁实现一个队列 type SliceQueue struct { data []interface{} mu sync.Mutex } func NewSlice 阅读全文
posted @ 2021-01-22 12:57
pebblecome
阅读(232)
评论(0)
推荐(0)
摘要:
编号1,2,3,4 的goroutine 每秒顺序打印 1,2,3,4 的编号 package main import ( "fmt" "time" ) //编号1,2,3,4 的goroutine 每秒顺序打印 1,2,3,4 的编号 type Token struct { } func work 阅读全文
posted @ 2021-01-22 12:55
pebblecome
阅读(102)
评论(0)
推荐(0)
摘要:
代码示例 package main import ( "bufio" "fmt" "math/rand" "os" "strings" "time" ) //使用channel简单实现消息队列 //1 func main() { ch := make(chan string,1) rand.Seed 阅读全文
posted @ 2021-01-22 12:53
pebblecome
阅读(785)
评论(0)
推荐(0)
摘要:
互斥锁 package main import ( "fmt" "sync" "time" ) //使用互斥锁计算时间 var( mu sync.Mutex x int64 wg sync.WaitGroup ) func write() { defer wg.Done() mu.Lock() x 阅读全文
posted @ 2021-01-22 12:51
pebblecome
阅读(90)
评论(0)
推荐(0)
摘要:
代码示例 package main import "fmt" //实现map reduce func mapChan(in chan interface{},fn func(interface{}) interface{}) chan interface{}{ out := make(chan in 阅读全文
posted @ 2021-01-22 12:49
pebblecome
阅读(332)
评论(0)
推荐(0)

浙公网安备 33010602011771号