当前位置:网站首页>[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 !
边栏推荐
- C4D quick start tutorial - Chamfer
- Tensorflow2 keras 分类模型
- 【Go实战基础】gin 高效神器,如何将参数绑定到结构体
- Qt的connect函数和disconnect函数
- 一个经典约瑟夫问题的分析与解答
- Openshift build image
- Dix ans d'expérience dans le développement de programmeurs vous disent quelles compétences de base vous manquez encore?
- Linux安装Oracle Database 19c
- win10使用docker拉取redis镜像报错read-only file system: unknown
- C# 高德地图 根据经纬度获取地址
猜你喜欢
随机推荐
Openshift deployment application
C Baidu map, Gaode map, Google map (GPS) longitude and latitude conversion
C4D quick start tutorial - Chamfer
Service de groupe minecraft
cmd窗口中中文呈现乱码解决方法
Don't spend money, spend an hour to build your own blog website
ORA-12514问题解决方法
选择排序和插入排序
Npoi export word font size correspondence
[blackmail virus data recovery] suffix Rook3 blackmail virus
Leetcode sword finger offer brush questions - day 23
Matplotlib剑客行——初相识Matplotlib
Oracle修改表空间名称以及数据文件
图像变换,转置
There is a problem with MySQL installation (the service already exists)
远程连接IBM MQ报错AMQ4036解决方法
Pclpy projection filter -- projection of point cloud to cylinder
gocv opencv exit status 3221225785
NPOI 导出Word 字号对应
随笔:RGB图像颜色分离(附代码)