内容简介:在解决网络问题:安装各种包:
在 $GOPATH 目录下新建一个项目目录(eg. gin_start ), 并在此项目根目录下初始化 mod :
go mod init gin_start
解决网络问题: export GOPROXY=https://goproxy.io (windows 使用 set )
安装各种包:
go get -v -u github.com/gin-gonic/gin
新建 main.go 写自己的代码:
package main
import (
"fmt"
"github.com/gin-gonic/gin"
)
func main() {
fmt.Printf("Start servering")
r := gin.Default()
r.GET("/hello", func(c *gin.Context) {
c.JSON(200, gin.H{
"success": true,
"code": 200,
"message": "Hello World",
"data": nil,
})
})
r.Run(":8000")
}
启动服务: go run main.go
访问: http://localhost:8000/hello
image.png
参考链接:
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- 使用logging管理爬虫
- 使用 MonoRepo 管理前端项目
- 使用Sphinx生成/管理文档
- RabbitMQ使用教程(二)RabbitMQ用户管理,角色管理及权限设置
- golang dep 依赖管理 使用
- 使用storybook管理React组件
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Open Data Structures
Pat Morin / AU Press / 2013-6 / USD 29.66
Offered as an introduction to the field of data structures and algorithms, Open Data Structures covers the implementation and analysis of data structures for sequences (lists), queues, priority queues......一起来看看 《Open Data Structures》 这本书的介绍吧!