当前位置:网站首页>GIN a preliminary study, the environment is installed
GIN a preliminary study, the environment is installed
2022-08-09 13:47:00 【One Leaf Knows Autumn @qqy】
前言
感谢开源项目gin-vue-admin,以及1010工作室的教程,项目文档
我只是在跟着学习,然后记录下笔记而已,可能会有新的代码加入,但是本质还是跟着学习的一个过程.
环境要求
Almost all are now in usemod管理包了,So it's definitely a requirementGO版本是1.1之上,本次直接使用GO1.16版本,That is, the latest1.16.6,goland采用2.21.2,Both use the latest version.
If there is an overseas link,So you can not set the following proxy.而且好像1.16Proxy is already used by default
go env -w GO111MODULE=on #设置全局开启 go mod Go1.16版本默认为on,可跳过这一步
go env -w GOPROXY=https://goproxy.cn,https://mirrors.aliyun.com/goproxy,direct #设置全局代理地址
创建项目
Create a project function folder in an external common place,然后打开goland.
点击File->New->Project
- step1
这里选择的GoThe implementation is used by defaultmod进行包管理,below herGo(gopath),It is the old way of package management,Not much to explain here,Because it has been gradually replaced by a way,Since it has been replaced, it means that there is something more powerful and convenient to replace,That is what is used nowmod. - step2
这里的locationIn fact, it is the path where the new project is located - step3
GOROOT很容易理解就是GO的安装路径.
最后点击Create
After the generated interface is to contain only onemod文件的,Then create your own project file inside it.
安装GIN包
点击goland底部的Terminal打开终端,输入下面的命令进行安装:
go get -v github.com/gin-gonic/gin
-v 可以省略
下载postman
百度搜索postman,进入官网进行下载,下载地址
Choose according to your platform.
下载完后,A user registration is required to open the session,Use your usual email address to do it,Or log in with Google Mailok的,Then open the software and press it together when it is ready. It should be similar to the interface below.
点击Woekspaces->My Workspace
然后点击Create a request,It is almost the same as being able to enter the interface belowOK
创建示例代码
package main
import "github.com/gin-gonic/gin"
func main() {
r := gin.Default() //启动gin路由,携带基础中间件启动
//Let the initiated route receiveget请求,且是/ping,Run an anonymous function,将gin的上下文传入
r.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
//Return the received information 回
"message": "pong",
})
})
r.Run() // listen and serve on 0.0.0.0:8080
}
在Goland中运行代码,然后再postman中进行验证
可以发现,再postmanThe result of the simulated request is the same as the one preset in the code
边栏推荐
- Rust from entry to proficient 04 - data types
- 单面线路板与精密多层PCB线路板区别有哪些?
- NFS pays special attention to the problem of permissions
- uni-app - uview Swiper 轮播图组件点击跳转链接(点击后拿到 item 行数据, 取出数据做操作)
- 史上最猛“员工”,疯狂吐槽亿万富翁老板小扎:那么有钱,还总穿着同样的衣服!...
- FPGA - Summary of bugs in ISE (in update)
- FFMPEG多媒体文件处理(ffmpeg文件的删除与重命名)
- telnet+ftp 对设备进行 操控 和 升级
- 5G 联通网管设计思路
- 剑指 Offer 43. 1~n 整数中 1 出现的次数(递归、数学)
猜你喜欢
FPGA中串口通信的时钟频率和波特率计数
Clock frequency and baud rate count for serial communication in FPGA
新起之秀 DPU,正在掀起数据中心变革!
uni-app - uview Swiper 轮播图组件点击跳转链接(点击后拿到 item 行数据, 取出数据做操作)
乐东消防救援大队应邀为干部开展消防安全培训
第六届“强网杯”全国网络安全挑战赛
FFmpeg多媒体文件处理(ffmpeg操作目录及list的实现)
快来扔鸡蛋。
Fragment中嵌套ViewPager数据空白页异常问题分析
安踏携手华为运动健康共同验证冠军跑鞋 创新引领中国体育
随机推荐
剑指 Offer 21. 调整数组顺序使奇数位于偶数前面(循环不变量)
Flutter Getting Started and Advanced Tour (8) Button Widget
联通网管协议框图
FFMPEG多媒体文件处理(ffmpeg文件的删除与重命名)
ftplib+ tqdm upload and download progress bar
5G China unicom general exception handling
十六进制字符→十进制数字
【TKE】GR+VPC-CNI混用模式下未产品化功能配置
基于 R 语言的深度学习——简单回归案例
About the handling of variable parameters in the Retrofit network request URL
R 语言 2010.1至2021.12艾滋病每月发病人数 时间序列分析
【FPGA教程案例48】图像案例8——基于FPGA的RGB图像转化为HSV图像的实现,通过MATLAB进行辅助验证
FFmpeg多媒体文件处理(FFMPEG日志系统)
Data Mining-06
JVM常用监控工具解释以及使用
驻波比计算方法
kustomize入门示例及基本语法使用说明
快来扔鸡蛋。
MySQL备份与恢复 (转载非原创)
用plot_hist_numeric()实现画直方图