当前位置:网站首页>[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 !
边栏推荐
- Concise analysis of redis source code 11 - Main IO threads and redis 6.0 multi IO threads
- Minecraft群組服開服
- Talk about the secret of high performance of message queue -- zero copy technology
- 分布式服务架构精讲pdf文档:原理+设计+实战,(收藏再看)
- 聊聊消息队列高性能的秘密——零拷贝技术
- 「面试高频题」难度大 1.5/5,经典「前缀和 + 二分」运用题
- Using recursive functions to solve the inverse problem of strings
- gocv图片裁剪并展示
- 《统计学习方法》——第五章、决策树模型与学习(上)
- Pyspark de duplication dropduplicates, distinct; withColumn、lit、col; unionByName、groupBy
猜你喜欢
Minecraft install resource pack
盘点典型错误之TypeError: X() got multiple values for argument ‘Y‘
Redis zadd导致的一次线上问题排查和处理
MYSQL安装出现问题(The service already exists)
十年开发经验的程序员告诉你,你还缺少哪些核心竞争力?
Installing Oracle database 19C RAC on Linux
commands out of sync. did you run multiple statements at once
【Go实战基础】gin 如何自定义和使用一个中间件
ORA-12514问题解决方法
我服了,MySQL表500W行,居然有人不做分区?
随机推荐
【Go实战基础】gin 高效神器,如何将参数绑定到结构体
Select sort and insert sort
There is a problem with MySQL installation (the service already exists)
How to realize asynchronous programming in a synchronous way?
寻找链表中值域最小的节点并移到链表的最前面
Minecraft群組服開服
Win10 uses docker to pull the redis image and reports an error read only file system: unknown
gocv边界填充
汉诺塔问题的求解与分析
Function ‘ngram‘ is not defined
Qunhui NAS configuring iSCSI storage
C nail development: obtain all employee address books and send work notices
1、 QT's core class QObject
CSDN Q & A_ Evaluation
Matplotlib剑客行——初相识Matplotlib
gocv opencv exit status 3221225785
Kubernetes deploys Loki logging system
Synchronize files using unison
Concise analysis of redis source code 11 - Main IO threads and redis 6.0 multi IO threads
小米电视不能访问电脑共享文件的解决方案