11 2022 档案

udp连接
摘要:服务端 package main import ( "fmt" "log" "net" ) func main(){ updaddr,err:=net.ResolveUDPAddr("udp","127.0.0.1:8003")//udp结构体 if err != nil { log.Println 阅读全文

posted @ 2022-11-28 16:56 孤灯引路人 阅读(140) 评论(0) 推荐(0) 编辑

tcp连接
摘要:服务器端 package main import ( "fmt" "net" "strings" ) func HandleConnect( conn net.Conn) { defer conn.Close() addr:=conn.RemoteAddr() fmt.Println(addr,"客 阅读全文

posted @ 2022-11-28 16:42 孤灯引路人 阅读(40) 评论(0) 推荐(0) 编辑

go模拟实现反向代理各种算法
摘要:package util type HttpServer struct { Host string Weight int } type LoadBalance struct { Server []*HttpServer CurrentIndex int } var MapWeight []int f 阅读全文

posted @ 2022-11-20 22:23 孤灯引路人 阅读(44) 评论(0) 推荐(0) 编辑

golang分层测试之http接口测试入门教程
摘要:前言 前几话主要讲解关于使用golang进行单元测试,在单元测试的上一层就是接口测试,本节主要讲使用golang进行接口测试,其中主要以http协议的接口测试来讲解 golang中的http请求 golang中拥有一个原生的http依赖库:net/http,http服务器的建立还是http客户端的开 阅读全文

posted @ 2022-11-18 16:03 孤灯引路人 阅读(341) 评论(0) 推荐(0) 编辑

4.golang http proxy反向代理
摘要:第一种方法 后端代码: package main import ( "io" "net/http" ) func web1Func( w http.ResponseWriter, r* http.Request){ io.WriteString(w,"<h1>this is test info we 阅读全文

posted @ 2022-11-18 14:24 孤灯引路人 阅读(396) 评论(0) 推荐(0) 编辑

3.go代理basic
摘要:1.通过代理转换 后端服务 package main import ( "encoding/base64" "log" "net/http" "os" "os/signal" "strings" ) type webHandler struct { } func (webHandler) Serve 阅读全文

posted @ 2022-11-16 17:12 孤灯引路人 阅读(30) 评论(0) 推荐(0) 编辑

Go之ioutil标准库
摘要:1.读取文件全部内容 path:="./src/test.txt" basepath,_:=filepath.Abs(path) file,_:=os.Open(basepath) defer file.Close() text,_:=ioutil.ReadAll(file) fmt.Println 阅读全文

posted @ 2022-11-15 16:31 孤灯引路人 阅读(48) 评论(0) 推荐(0) 编辑

Go之filepath标准库
摘要:1. ToSlash 函数:func ToSlash(path string) string 释义: 将 path 中平台相关的路径分隔符转换为 '/' s := "F:\\golang_workspace\\leetcode\\aa.js" fmt.Println("path: ", s) s = 阅读全文

posted @ 2022-11-15 16:09 孤灯引路人 阅读(91) 评论(0) 推荐(0) 编辑

2.go做baseic
摘要:代码 package main import ( "encoding/base64" "log" "net/http" "os" "os/signal" "strings" ) type webHandler struct { } func (webHandler) ServeHTTP (w htt 阅读全文

posted @ 2022-11-13 23:10 孤灯引路人 阅读(25) 评论(0) 推荐(0) 编辑

1.go做反向代理
摘要:后端服务器代码 package main import ( "log" "net/http" "os" "os/signal" ) type webHandler struct { } func (webHandler) ServeHTTP (w http.ResponseWriter, reque 阅读全文

posted @ 2022-11-13 23:01 孤灯引路人 阅读(99) 评论(0) 推荐(0) 编辑

Go之time包日期操作,时间戳与日期相互转换
摘要:在Go中,时间操作需要导入time包 获取当前时间 package main import ( "fmt" "time" ) func main() { // 获取当前时间 t := time.Now() fmt.Printf("now=%v\n", t) /* time.Now() 返回类型为ti 阅读全文

posted @ 2022-11-12 21:05 孤灯引路人 阅读(569) 评论(0) 推荐(0) 编辑

Golang学习日志 ━━ 理解依赖包的管理(mod/非mod)和加载方式(项目路径、相对路径、绝对路径)及实战运用
摘要:go有很多种方法调用依赖包,mod又加入了对包的版本管理。方式太多不免有令人迷惑和混乱的地方,希望本文能帮助大家了解目前使用规则 一、mod / 非mod 管理方式go提供了两种项目依赖包的管理方式,一种是mod方式,一种是非mod方式 1. mod方式 main.go里面的代码 package m 阅读全文

posted @ 2022-11-07 22:58 孤灯引路人 阅读(201) 评论(0) 推荐(0) 编辑

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示