随笔分类 - go
学习了解quic go
摘要:不要通过共享内存来通信,而应该通过通信来共享内存 这个是golang社区的经典语 说的是什么意思呢? 之前使用C代码进行性能优化的时候,遇到了很多高性能的架构,但是其只依赖于高性能的MPSC队列(queue普遍使用的原子锁,offset,count都使用CAS操作),而从来不在事务逻辑里用锁 那应该
阅读全文
摘要:net/http 中同时包好了 HTTP 客户端和服务端的实现,为了支持更好的扩展性,它引入了 net/http.RoundTripper 和 net/http.Handler 两个接口。net/http.RoundTripper 是用来表示执行 HTTP 请求的接口,调用方将请求作为参数可以获取请
阅读全文
摘要:目前知道gin是基于net/http进一步封装,来看下net/http是怎样写web的 package main import ( "fmt" "net/http" ) func index(w http.ResponseWriter, r *http.Request) { fmt.Fprintln
阅读全文
摘要:package main import ( "net/http" "github.com/gin-gonic/gin" ) func main() { r := gin.Default() r.GET("/", func(c *gin.Context) { c.String(200, "Hello!
阅读全文
摘要:切换了一下go env -w GOPROXY="https://goproxy.cn,direct" proxy go mod tidy 就好了 可能是aliyun代理上缺少什么东西把 !!!!!!!!!!!!
阅读全文
摘要:客户端: 接收配置的conn 也就是客户端监听8888端口收集config_client配置,重新封装送到隧道里面去 服务端: 将客户端8888 配置转发到server端8877 解封装。然后对比每个配置文件版本号。 如果版本不一样。server 重新封装配置。下发到客户端的8888.,客户端888
阅读全文
摘要:测试环境如下: centosA:192.168.1.206 ./chisel client -v 192.168.1.207:12345 192.168.1.206:8888:socks centosB:192.168.1.207 ./chisel server -v --host 192.168.
阅读全文
摘要:转载自gossh协议库 导读 SSH, The Secure Shell Protocol (安全 Shell 协议),是一个使用广泛的网络协议。 在中文互联网世界,关于 SSH 协议的介绍,往往都把重点放到了安全(Secure)方面的细节。这样的文章对于开发者来说,意义并不大,原因在于: 此类文章
阅读全文
摘要:目前chisel基于tcp http websocket 的ssh 代理!! chisel 代理流程client<<--tcp/udp/socks-->>http->chisel-client<< ####tcp-http-websocket-ssh#### >>chisel-server<< tc
阅读全文
摘要:Writer和Reader是两个抽象的接口,其定义如下 type Writer interface { Write(p []byte) (n int, err error) } type Reader interface { Read(p []byte) (n int, err error) } 查
阅读全文
摘要:在分析chiesl 的时候涉及到代理 Proxy,代理的本质,是转发两个相同方向路径上的 stream(数据流)。例如,一个 A-->B-->C 的代理模式,B 作为代理,读取从 A >B 的数据,转发到 B >C func Pipe(src io.ReadWriteCloser, dst io.R
阅读全文
摘要:var user dot1xDataItem user.UserName = "test11" dot1xDb.Find(&user) 执行路径:一样 只是在 BuildQuerySQL的时候 会解析传进来参数里面的values,有值就当做where exp eq 处理 func BuildQuer
阅读全文
摘要:var users []dot1xDataItem dot1xDb.Where("user_name = ? AND client_macaddr = ?", "test1", "88:A4:C2:D9:27:AE").Find(&users) 来看看这行代码是怎样组装sql语句 // Where
阅读全文
摘要:gorm 相互关联 // Config GORM config type Config struct { Dialector callbacks *callbacks cacheStore *sync.Map } // DB GORM DB definition type DB struct { *
阅读全文
摘要:创建orm db handle 后, 对schema migrate // Migrate the schema dot1xDb.AutoMigrate(&dot1xDataItem{}) 初始化创建open orm时;一开始dot1xDb的clone变量为1 tmp := sqlite.Open(
阅读全文
摘要:GORM本身是构建在 database/sql 之上的 dot1xpath := gAppCfg.RuntimeConfigPath + "dot1x.db" dot1xsql, err = sql.Open("sqlite3", dot1xpath) if err != nil { return
阅读全文
摘要:{ http.HandleFunc("/device_status", radiusAccountHandler) err := http.ListenAndServe(":8000", nil) } func radiusAccountHandler(w http.ResponseWriter,
阅读全文
摘要:字符串高效拼接 常见方式:使用+ 使用fmt.Sprintf 效率比较高的: strings.Builder func builderConcat(n int, str string) string { var builder strings.Builder for i := 0; i < n; i
阅读全文
摘要:目前使用gout 作为http客户端, 处理数据时看到了respone数据解析。 首先看解析respone header数据: 目前看代码的核心设计逻辑: 1、创建一个Header = headerDecode{} 实例 2、调用实例的(h *headerDecode) Decode(rsp *ht
阅读全文
摘要:目前对于反射使用不是很熟悉,记录之 if val.Kind() == reflect.Interface { val = reflect.ValueOf(val.Interface()) } switch t := val.Kind(); t { case reflect.Uint, reflect
阅读全文