go之gin环境搭建

1、go环境
  • go环境:go version go1.15.2 windows/amd64
  • windows:win10旗舰版
  • IDE:vs code
2、gin项目依赖

主工程项目

在github.com文件夹下:

git clone https://github.com/gin-gonic/gin.git gin-gonic/gin

依赖工程:

在github.com文件夹下:

  • git clone https://github.com/gin-contrib/sse.git gin-contrib/sse
  • git clone https://github.com/go-playground/universal-translator.git go-playground/
    universal-translator
  • git clone https://github.com/leodido/go-urn.git leodido/go-urn
  • git clone https://github.com/mattn/go-isatty.git mattn/go-isatty
  • git clone https://github.com/ugorji/go.git ugorji/go
  • git clone https://github.com/go-playground/validator.git go-playground/validator/
  • git clone https://github.com/golang/protobuf.git golang/protobuf
  • git clone https://github.com/go-playground/locales.git go-playground/locales

在golang.org/x文件夹下:

  • git clone https://github.com/golang/crypto.git crypto

在google.golang.org文件夹下:

  • git clone https://e.coding.net/robinqiwei/googleprotobuf.git protobuf

在src文件夹下:

  • git clone https://github.com/go-yaml/yaml.git gopkg.in/yaml.v2
3、gin环境测试

在src目录下面建立一个工程:

目录结构如下:

  • src
    • ginstudy
      • main
        • main.go

main.go文件内容:

package main
import "github.com/gin-gonic/gin"
func main() {
	TestGin()
}
func TestGin() {
	r := gin.Default()
	r.GET("/", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"Blog":   "https://blog.csdn.net/xiazhipeng1000",
			"wechat": "xxxxxx",
		})
	})
	r.Run()
}

将上面文件的内容复制到main.go中,在src/ginstudy/main/文件夹下,输入如下的命令,启动服务:

go run .\main.go

在这里插入图片描述

在本地的浏览器中输入网址,测试网站启动情况:

http://localhost:8080/

在这里插入图片描述

如果出现如上的界面说明你的gin已经安装好了。

另附福利:gin的package依赖环境打包:

链接:https://pan.baidu.com/s/1nhrDPOMFo1IPaxfSnHeutw
提取码:y250

有啥不对的地方,希望大家指正哈!

感兴趣的朋友可以关注下面的公众号,每天分享一点知识,成长看得见,感谢支持!!
在这里插入图片描述

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值