go语言
gaozhen575
这个作者很懒,什么都没留下…
展开
-
1. 搭建项目 go原生http库项目
1. 搭建项目 go原生http库项目package mainimport ( "encoding/json" "log" "net/http")type IndexData struct { Title string `json:"title"` Desc string `json:"desc"`}func index(w http.ResponseWriter,r *http.Request) { w.Header().Set("Content-Type","a.原创 2022-04-20 22:07:43 · 207 阅读 · 0 评论 -
gin框架项目 待办清单
Go web开发系列教程,基于Gin框架和GORM的练手小项目。源码地址:https://github.com/Q1mi/bubblepackage mainimport ( "github.com/gin-gonic/gin" "gorm.io/driver/mysql" "gorm.io/gorm" "net/http")type Todo struct { ID int `json:"id"` Title string `json:"title"` Status..原创 2022-04-19 17:17:46 · 232 阅读 · 0 评论 -
go框架gin路由
package mainimport ( "github.com/gin-gonic/gin" "net/http")func main() { r:=gin.Default() r.GET("/index", func(c *gin.Context) { c.JSON(http.StatusOK,gin.H{ "method":"GET", }) }) r.POST("/index", func(c *gin.Context) { c.JSON(http.Sta.原创 2022-04-11 10:44:41 · 433 阅读 · 0 评论 -
go gin框架中间件
go gin框架中间件中间件也叫拦截器或者过滤器,这些中间件会在路由之前执行,以此完成一些特定功能,比如打印日志啊、登录认证、权限认证、错误返回等。package mainimport ( "fmt" "github.com/gin-gonic/gin" "net/http" "time")func indexHandler(c *gin.Context){ fmt.Println("index in ") c.JSON(http.StatusOK,gin.H{原创 2022-04-10 16:42:10 · 543 阅读 · 0 评论 -
go语言json序列化
go语言json序列化key-value (结构体,map,切片)序列化为json字符串操作package mainimport ( "encoding/json" "fmt")type Monster struct { Name string Age int Birthday string Sal float64 Skill string}func testStruct() { monster:= Monster{ Name: "jack", Age:原创 2022-04-09 17:42:28 · 1322 阅读 · 0 评论 -
go协程/goroutine
package mainimport ( "fmt" "runtime" "sync" "time")////func test(){// for i:=1;i<10;i++{// fmt.Println("hello world"+ strconv.Itoa(i))// time.Sleep(time.Second)// }//}var( myMap=make(map[int]int,10) //lock全局互斥锁 synchornized // mute.原创 2022-04-05 18:28:05 · 174 阅读 · 0 评论 -
项目开发流程
家庭收记账原创 2022-04-04 11:46:30 · 221 阅读 · 0 评论 -
go语言断言
go语言断言原创 2022-04-04 11:25:00 · 185 阅读 · 0 评论