当前位置:网站首页>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
边栏推荐
猜你喜欢
在“Extend the Omniverse”比赛中构建用于 3D 世界的工具
造自己的芯,让谷歌买单!谷歌再度开源 180nm 工艺的芯片
绘制混合密度函数图以及添加分位数线
Flutter entry and advanced tour (6) Layout Widget
5G Unicom Network Management Design Ideas
Jenkins API groovy调用实践: Jenkins Core Api & Job DSL创建项目
面试题精选:神奇的斐波那契数列
How to reduce the size of desktop icons after the computer is reinstalled
Rust 入门指南(使用JSON)
FFmpeg多媒体文件处理(ffmpeg操作目录及list的实现)
随机推荐
5G 联通网管设计思路
电脑重装系统还原0x80070005错误如何解决
RTSP协议的实现
一维数组&指针
WebView injects Js code to realize large image adaptive screen click image preview details
MySQL5.6到8.0的账号迁移
Rust 入门指南(使用JSON)
快来扔鸡蛋。
在“Extend the Omniverse”比赛中构建用于 3D 世界的工具
leetcode 20. Valid Parentheses 有效的括号(中等)
Dry+Bean+Dataset R语言数据分析,报告英文
ftplib+ tqdm upload and download progress bar
LeetCode 37.解数独
Flutter entry and advanced tour (6) Layout Widget
NFS pays special attention to the problem of permissions
read stream special attention
Go Affair, How to Become a Gopher and Find a Go Job in 7 Days, Part 1
Standing wave ratio calculation method
Microsoft 10/11 命令行打开系统设置页(WUAP,!WIN32)
[MRCTF2020]套娃-1