Download and install it:
$ go get github.com/gin-gonic/gin
Import it in your code:
import "github.com/gin-gonic/gin"
(Optional) Import net/http. This is required for example if using constants such as http.StatusOK.
import "net/http"
router := gin.Default()
router.GET("/someGet", getting)
router.POST("/somePost", posting)
// By default it serves on :8080 unless a
// PORT environment variable was defined.
router.Run() // router.Run(":3000") for a hard coded port
Run your project
$ go run main.go
func main() {
router := gin.Default()
// Query string parameters are parsed using the existing underlying request object.
// The request responds to a url matching: /welcome?firstname=Jane&lastname=Doe
router.GET("/welcome", func(c *gin.Context) {
firstname := c.DefaultQuery("firstname", "Guest")
lastname := c.Query("lastname") // shortcut for c.Request.URL.Query().Get("lastname")
c.String(http.StatusOK, "Hello %s %s", firstname, lastname)
})
router.Run(":8080")
}

gin入门的更多相关文章

  1. gin入门-1

    Gin框架介绍 1. 简介Gin框架介绍A. 基于httprouter开发的web框架.http://github.com/julienschmidt/httprouterB. 提供Martini风格 ...

  2. Gin + Vue全栈开发实战(一)

    Gin入门 本章概要 Gin简介 开发第一个Gin程序 1.1 Gin简介 Gin是用Go语言编写的一个轻量级Web应用框架,现在在各个公司包括字节跳动.bilibili等大互联网公司都得到了广泛的应 ...

  3. Golang Gin实践 番外 请入门 Makefile

    Golang Gin实践 番外 请入门 Makefile 原文地址:Golang Gin实践 番外 请入门 Makefile 前言 含一定复杂度的软件工程,基本上都是先编译 A,再依赖 B,再编译 C ...

  4. Go最火的Gin框架简单入门

    Gin 介绍 Gin 是一个 Golang 写的 web 框架,具有高性能的优点,,基于 httprouter,它提供了类似martini但更好性能(路由性能约快40倍)的API服务.官方地址:htt ...

  5. GO语言GIN框架入门

    Gin框架介绍 Gin是一个用Go语言编写的web框架.它是一个类似于martini但拥有更好性能的API框架, 由于使用了httprouter,速度提高了近40倍. 中文文档 Gin框架安装与使用 ...

  6. 【Go语言系列】第三方框架和库——GIN:快速入门

    要求要安装Gin软件包,需要:1.安装Go(需要1.11+版本)2.设置Go工作区 安装1.下载并安装 gin: $ go get -u github.com/gin-gonic/gin 2.将 gi ...

  7. 01 . Go框架之Gin框架从入门到熟悉(路由和上传文件)

    Gin框架简介 Gin是使用Go/Golang语言实现的HTTP Web框架, 接口简洁, 性能极高,截止1.4.0版本,包含测试代码,仅14K, 其中测试代码9K, 也就是说测试源码仅5k左右, 具 ...

  8. 02 . Go框架之Gin框架从入门到熟悉(数据解析和绑定,渲染,重定向,同步异步,中间件)

    数据解析和绑定 json数据解析和绑定 package main import ( "github.com/gin-gonic/gin" "net/http" ...

  9. 03 . Go框架之Gin框架从入门到熟悉(Cookie和Session,数据库操作)

    Cookie Cookie是什么 HTTP是无状态协议,服务器不能记录浏览器的访问状态,也就是说服务器不能区分两次请求是否由同一个客户端发出 Cookie就是解决HTTP协议无状态的方案之一,中文是小 ...

随机推荐

  1. 给你的webstorm添加快速生成注释得快捷键

    打开File----setting-map-搜搜"fix doc"

  2. Number Sequence_hdu_1005(规律)

    9329854 2013-10-13 14:36:41 Accepted 1005 171MS 5072K 654 B Java zhangyi http://acm.hdu.edu.cn/showp ...

  3. Struts2之文件上传(单文件/多文件)

    <一>简述: Struts2的文件上传其实也是通过拦截器来实现的,只是该拦截器定义为默认拦截器了,所以不用自己去手工配置,<interceptor name="fileUp ...

  4. profiler跟踪事件模板文件

    查找执行情况最差的查询. 例如,可以创建一个捕获与 TSQL 和 Stored Procedure 事件类(RPC:Completed 和SQL:BatchCompleted)相关的事件的跟踪.在此跟 ...

  5. Java入门到精通——调错篇之Eclipse No Java virtual machine was found after searching the following locations

    一.错误现象. 在一次启动Eclipse的时候弹出了以下的错误 二.错误原因 原因是没有找到javaw.exe文件的路径. 三.解决方式 在eclipse根文件夹下找到eclipse.ini增加以下一 ...

  6. SyntaxError: Non-ASCII character '\xe5' in file index.py on line 6, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

    python入门,hhh 在慕课网上学习python入门,编写汉诺塔的递归调用时,代码正确.但是加上注释后编译不通过 报如下错误: SyntaxError: Non-ASCII character , ...

  7. Linux命令-帮助命令:whatis,apropos

    whatis可以查看命令简化版的帮助内容 whatis ls 查看简化版的ls命令的帮助内容 whatis ifconfig 查看简化版的ifconfig命令的帮助内容 apropos可以查看配置文件 ...

  8. struts2开发流程及配置,域对象对数据存储的3种方式

    一.开发流程 1)引入 jar 包,其中必须引入的有(我是用的struts是2.3.32) commons-fileupload-1.3.2.jar     |文件上传下载commons-io-2.2 ...

  9. C++ vector 和 map的删除

    1.连续内存序列容器(vector,string,deque) 序列容器的erase方法返回值是指向紧接在被删除元素之后的元素的有效迭代器,可以根据这个返回值来安全删除元素. vector<in ...

  10. Atitit.注解解析(1)---------词法分析 attilax总结 java .net

    Atitit.注解解析(1)---------词法分析 attilax总结  java .net 1. 应用场景:::因为要使用ui化的注解 1 2. 流程如下::: 词法分析(生成token流) & ...