摘要: 要支持任一类型的值,该单个函数将需要一种方法来声明它支持的类型。另一方面,调用代码需要一种方法来指定它是使用整数映射还是浮点映射。 package main import "fmt" func main() { // Initialize a map for the integer values i 阅读全文
posted @ 2022-03-16 15:06 搬砖__码农 阅读(70) 评论(0) 推荐(0)
摘要: 代码 package main import ( "errors" "net/http" "strings" "time" "github.com/gin-gonic/gin" "github.com/golang-jwt/jwt" ) func main() { // gin.Default 会使 阅读全文
posted @ 2022-02-17 22:46 搬砖__码农 阅读(262) 评论(0) 推荐(0)
摘要: package main import ( "fmt" "reflect" "strings" ) type Student struct { Name string Age int Addr string } // 遍历结构体, 只遍历,不做修改 func forStruct_1() { s := 阅读全文
posted @ 2022-02-17 22:41 搬砖__码农 阅读(387) 评论(0) 推荐(0)
摘要: package main import ( "fmt" "runtime" "sync" "time" ) func main() { ch := make(chan int, runtime.NumCPU()) // 定义一个有缓冲的channel wg := sync.WaitGroup{} f 阅读全文
posted @ 2021-11-03 21:27 搬砖__码农 阅读(90) 评论(0) 推荐(0)
摘要: 总的来说与多线程的实现方式几乎一致. 不同的点在于多进程间的变量通信 from multiprocessing import Process import time import os class MyProcess(Process): def __init__(self): super().__i 阅读全文
posted @ 2021-09-08 00:33 搬砖__码农 阅读(103) 评论(0) 推荐(0)
摘要: 话不多说, 直接上代码 from threading import Thread, Lock import time import dis globalVar = [0] lock = Lock() class MyThread(Thread): def __init__(self): super( 阅读全文
posted @ 2021-09-07 19:43 搬砖__码农 阅读(66) 评论(0) 推荐(0)
摘要: 1. github地址 2. 安装方式 docker 部署 docker build -t x/file_server . docker run -p 8080:8080 -itd x/file_server app 部署 go build -o app . ./app 打开浏览器访问 localh 阅读全文
posted @ 2021-05-11 11:14 搬砖__码农 阅读(1502) 评论(0) 推荐(0)
摘要: package main import ( "fmt" "sort" ) type SortByGszzl []map[string]string // 设置自定义类型 // 一个内置的排序算法需要知道三个东西: // 1.序列的长度, Len // 2.表示两个元素比较的结果,Less // 3. 阅读全文
posted @ 2021-04-28 10:52 搬砖__码农 阅读(1163) 评论(0) 推荐(0)
摘要: package main import ( "fmt" "log" "gopkg.in/yaml.v2" ) func test_parse_yaml() { data := []byte(` name: GOLANG say: f: hello b: world say2: - f: hello 阅读全文
posted @ 2021-04-28 00:07 搬砖__码农 阅读(244) 评论(0) 推荐(0)
摘要: package main import ( "encoding/json" "fmt" "log" ) var json_data = []byte(` { "name" : "Golang", "say" : ["Hello", "World!"] } `) type Data struct { 阅读全文
posted @ 2021-04-13 22:46 搬砖__码农 阅读(3982) 评论(0) 推荐(0)
点击右上角即可分享
微信分享提示