当前位置:网站首页>[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 !
边栏推荐
- What is the future value of fluorite mine of karaqin Xinbao Mining Co., Ltd. under zhongang mining?
- 一、Qt的核心类QObject
- [staff] common symbols of staff (Hualian clef | treble clef | bass clef | rest | bar line)
- PCL calculates the intersection of three mutually nonparallel planes
- Connect function and disconnect function of QT
- Don't spend money, spend an hour to build your own blog website
- Qt的connect函数和disconnect函数
- 选择排序和插入排序
- MYSQL安装出现问题(The service already exists)
- commands out of sync. did you run multiple statements at once
猜你喜欢

Linux安装Oracle Database 19c

2022/2/13 summary

ORA-12514问题解决方法

Matplotlib swordsman Tour - an artist tutorial to accommodate all rivers

【Go实战基础】gin 如何设置路由

《统计学习方法》——第五章、决策树模型与学习(上)

How to realize asynchronous programming in a synchronous way?

Minecraft group service opening

Avoid breaking changes caused by modifying constructor input parameters

oracle修改数据库字符集
随机推荐
Qt的拖动事件
commands out of sync. did you run multiple statements at once
以字节跳动内部 Data Catalog 架构升级为例聊业务系统的性能优化
Mysql安装时mysqld.exe报`应用程序无法正常启动(0xc000007b)`
Redis安装部署(Windows/Linux)
队列的基本概念介绍以及典型应用示例
Linux二进制安装Oracle Database 19c
Minecraft群組服開服
Matplotlib剑客行——没有工具用代码也能画图的造型师
Introduction to the basic concept of queue and typical application examples
Concise analysis of redis source code 11 - Main IO threads and redis 6.0 multi IO threads
gocv图片读取并展示
Shengshihaotong and Guoao (Shenzhen) new energy Co., Ltd. build the charging pile industry chain
C language implementation of mine sweeping game
队列管理器running状态下无法查看通道
There is a problem with MySQL installation (the service already exists)
《统计学习方法》——第五章、决策树模型与学习(上)
Don't spend money, spend an hour to build your own blog website
Right click menu of QT
Illegal use of crawlers, an Internet company was terminated, the police came to the door, and 23 people were taken away
