当前位置:网站首页>[go practical basis] how to install and use gin
[go practical basis] how to install and use gin
2022-07-02 09:08:00 【Novice practice】
Catalog
3、 ... and 、 Rookie actual combat
One 、 brief introduction
What is? Gin ,Gin It's a golang The micro framework of , The packaging is elegant ,API friendly , The source code comments are relatively clear , Fast and flexible , Fault tolerance and convenience
install : go get -u github.com/gin-gonic/gin
Two 、 Knowledge point
- gin install
- gin start-up
- gin Basic routing
- gin return JSON data
3、 ... and 、 Rookie actual combat
Actual combat scene : use Go Realize installation and use gin
Make arrangements now !
1、 establish go file
/*
* @Author: Rookie actual combat
* @Description: How to install and use gin
*/
/*
Gin It's a golang The micro framework of , The packaging is elegant ,API friendly , The source code comments are relatively clear , Fast and flexible , Fault tolerance and convenience
install : go get -u github.com/gin-gonic/gin
*/
// Knowledge point :
// # gin install
// # gin start-up
// # gin Basic routing
// # gin return JSON data
package main
// Import package
import (
"fmt"
"github.com/gin-gonic/gin"
"runtime"
)
// The main function
func main() {
// Print using built-in functions
println("Hello", " Rookie actual combat ")
println(" Actual combat scene : ", " How to install and use gin")
// initialization
r := gin.Default()
// Add routes and callbacks
r.GET("/ping", func(c *gin.Context) {
// Back to code and Corresponding structure information
c.JSON(200, gin.H{
"message": "pong",
})
})
// Use package functions to print
fmt.Printf(" edition : %s \n", runtime.Version())
// Start the framework program , Default 8080 port
r.Run()
}
2、 Running results
Hello Rookie actual combat
Actual combat scene : How to install and use gin
[GIN-debug] Listening and serving HTTP on :8080
Rookie actual combat , Continuous learning !
边栏推荐
- 一个经典约瑟夫问题的分析与解答
- WSL安装、美化、网络代理和远程开发
- C # save web pages as pictures (using WebBrowser)
- gocv图片读取并展示
- Matplotlib剑客行——没有工具用代码也能画图的造型师
- Redis sorted set data type API and application scenario analysis
- Image transformation, transpose
- Data type case of machine learning -- using data to distinguish men and women based on Naive Bayesian method
- C#钉钉开发:取得所有员工通讯录和发送工作通知
- Installing Oracle database 19C for Linux
猜你喜欢

队列管理器running状态下无法查看通道
![[staff] time sign and note duration (full note | half note | quarter note | eighth note | sixteenth note | thirty second note)](/img/bf/2b0b9c640bdad2c55293f905a22055.jpg)
[staff] time sign and note duration (full note | half note | quarter note | eighth note | sixteenth note | thirty second note)

Installing Oracle database 19C RAC on Linux
![[blackmail virus data recovery] suffix Rook3 blackmail virus](/img/46/debc848d17767d021f3f41924cccfe.jpg)
[blackmail virus data recovery] suffix Rook3 blackmail virus

Minecraft空岛服开服

Talk about the secret of high performance of message queue -- zero copy technology

Qunhui NAS configuring iSCSI storage

京东面试官问:LEFT JOIN关联表中用ON还是WHERE跟条件有什么区别

Matplotlib剑客行——没有工具用代码也能画图的造型师

Kubernetes deploys Loki logging system
随机推荐
Oracle修改表空间名称以及数据文件
gocv opencv exit status 3221225785
Minecraft group service opening
使用递归函数求解字符串的逆置问题
查看was发布的应用程序的端口
WSL安装、美化、网络代理和远程开发
C language - Blue Bridge Cup - 7 segment code
Redis sorted set data type API and application scenario analysis
【Go实战基础】gin 高效神器,如何将参数绑定到结构体
一个经典约瑟夫问题的分析与解答
Aneng logistics' share price hit a new low: the market value evaporated by nearly 10 billion yuan, and it's useless for chairman Wang Yongjun to increase his holdings
C# 高德地图 根据经纬度获取地址
Redis zadd导致的一次线上问题排查和处理
2022/2/14 summary
C# 调用系统声音 嘀~
Sentinel reports failed to fetch metric connection timeout and connection rejection
Kubernetes deploys Loki logging system
Leetcode sword finger offer brush questions - day 22
AMQ6126问题解决思路
Gocv image cutting and display
