文章分类 -  golang

golang学习
摘要:###1、解析和绑定JSON数据-ShouldBindJSON 通过ShouldBindJSON 解析从body里的数据 ctx.ShouldBindJSON(&jsonData) type Login struct { // binding:"required"修饰的字段,若接收为空值,则报错,是 阅读全文
posted @ 2023-02-04 11:00 amu2018 阅读(217) 评论(0) 推荐(0) 编辑
摘要:https://www.topgoer.com/gin%E6%A1%86%E6%9E%B6/gin%E8%B7%AF%E7%94%B1/%E8%B7%AF%E7%94%B1%E6%8B%86%E5%88%86%E4%B8%8E%E6%B3%A8%E5%86%8C.html https://blog. 阅读全文
posted @ 2023-02-01 09:06 amu2018 阅读(31) 评论(0) 推荐(0) 编辑
摘要:一、VSCode直接安装出现以下失败的情况: Installing github.com/mdempsky/gocode FAILED Installing github.com/ramya-rao-a/go-outline FAILED Installing github.com/acroca/g 阅读全文
posted @ 2022-07-26 10:00 amu2018 阅读(220) 评论(0) 推荐(0) 编辑
摘要:一、interface 定义 //接口是一个规范 type InterfaceName interface{ functionA() functionB(param1 paramType)(returnType,returnType) } 二、接口实现 2.1 通过结构体或者通过自定义类型实现接口, 阅读全文
posted @ 2022-05-15 15:33 amu2018 阅读(26) 评论(0) 推荐(0) 编辑
摘要:一、RPC工作流程: 摘自《go web编程》 二、go支持三个级别的RPC( HTTP,TCP,JSONRPC) 三、实现http的RPC实例: 3.1 GO RPC的函数只有符合以下条件才能被远程访问 函数必须是首字母是大写 必须有两个首字母大写的参数 第一个参数是接收的参数,第二个参数是返回给 阅读全文
posted @ 2022-05-11 00:44 amu2018 阅读(225) 评论(0) 推荐(0) 编辑
摘要:一、搭建redis-server https://www.cnblogs.com/amuge/articles/16215516.html 二、golang支持redis的驱动有以下几个 及 github.com/astaxie/redisgo 三、简单实现连接goredis 3.1 安装 go m 阅读全文
posted @ 2022-05-02 16:14 amu2018 阅读(109) 评论(0) 推荐(0) 编辑
摘要:一、安装驱动 go get -u github.com/go-sql-driver/mysql 二、代码编写 package main import ( "database/sql" "fmt" "log" _ "github.com/go-sql-driver/mysql" ) func main 阅读全文
posted @ 2022-04-29 22:02 amu2018 阅读(536) 评论(1) 推荐(0) 编辑