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. ACCESS数据库如何设置密码

    首先是文件-关闭数据库   打开-找到这个文件,然后以独占方式打开   然后文件-设置数据库密码,比如输入123作为密码,下次再打开数据库的时候就会要求输入密码                     ...

  2. Simple TCP/IP Echo Server & Client Application in C#

    1. TCP Server The server’s job is to set up an endpoint for clients to connect to and passively wait ...

  3. object sender, LinkLabelLinkClickedEventArgs e 参数解释

    开始是一个LinkLabel 控件,LinkLabel 绑定了Clicke事件 LinkLabel Delete = new LinkLabel(); Delete.Text = "删除&q ...

  4. CentOS6.5搭建MySQL5.1主从复制

    环境: mysql> select version(); +------------+ | version() | +------------+ | 5.1.73-log | +-------- ...

  5. Warning: cast to/from pointer from/to integer of different size

    将int变量转为(void*)时出现错误 error: cast to pointer from integer of different size [-Werror=int-to-pointer-c ...

  6. jsp标签(jsp动作元素)

    <jsp:forward page=”/index.jsp”></jsp:forward>也是跳转. 可以用来配置为首页,来启动某个servlet. <jsp:inclu ...

  7. Thrift实现C#调用Java开发步骤详解

    概述 Thrift实现C#调用Java开发步骤详解 详细 代码下载:http://www.demodashi.com/demo/10946.html Apache Thrift 是 Facebook ...

  8. Python-搭建Nginx+Django环境

    1.安装 flup 模块 下载:http://projects.unbit.it/downloads/uwsgi-latest.tar.gz 安装:python setup.py install 2. ...

  9. Ubuntu下设置redis让其他服务器访问

    修改redis配置文件,将 bind 127.0.0.1to bind 0.0.0.0Then restart your service (service redis-server restart) ...

  10. php简单混淆类加密文件如何解密?

    最近在整理单位购买的源码时,发现源码里好多文件都混淆加密了.虽然不解密也不影响使用,但是心里总觉得有些别扭,便试着将加密的文件解密. 首先,百度了一下,看网上是否有现成的混淆类解密工具,搜到了一个ht ...