golang
已收录文章:14414篇
-
使用httptest可无需启动服务器测试HTTPHandler。1.用httptest.NewRequest创建请求;2.用httptest.NewRecorder记录响应;3.调用Handler并验证状态码、响应体等。支持查询参数、路径参数、POST数据及Header、Cookie、重定向检查,需覆盖各类状态码与边界情况。432 收藏
-
一、基本使用 ①从属于time这个包 ②一般使用都是使用 time.Time 这个类型表示时间 ,time包中还有一些常量,源码如下 // Common durations. There is no definition for units of Day or larger // to avoid confusion across431 收藏
-
Golang Goroutine和线程的区别 Golang,轻松学习 一、Golang Goroutine? 当使用者分配足够多的任务,系统能自动帮助使用者把任务分配到 CPU 上,让这些任务尽量并发运作。这种机制在 Go语言中被称为 g431 收藏
-
底层报错 error:cannot assign requested address 原因 并发场景下 client 频繁请求端口建立tcp连接导致端口被耗尽 解决方案 root执行即可 sysctl -w net.ipv4.tcp_timestamps=1 开启对于TCP时间戳的支持,若该项设置431 收藏
-
文件目录的创建和删除 package main import( "fmt" "os" ) func main(){ //创建目录和权限 os.Mkdir("./benben",0777) //创建多级目录和设置权限 os.MkdirAll("./benben/test",0777) //删除目录 err:=os.Remove("./benben") i431 收藏
-
前言 我研究了file库,终于让我找到了利用Go语言追加内容到文件末尾的办法 主要的2个函数: func (f *File) Seek(offset int64, whence int) (ret int64, err error) func (f *File) WriteAt(b []byte, off int64) (n int, err erro431 收藏