golang web框架Gin入门1-环境搭建

作者: dreamfly 分类: go,个人博客 发布时间: 2020-06-10 10:37

golang

Go(又称 Golang)是 Google 的 Robert Griesemer,Rob Pike 及 Ken Thompson 开发的一种静态强类型、编译型语言。Go 语言语法与 C 相近,但功能上有:内存安全,GC(垃圾回收),结构形态及 CSP-style 并发计算。

Gin

Gin是go语言开发的一个HTTP高性能web框架,它有着Martini风格的API,但是性能却是Martini的40倍,同样,他提供丰富的功能,可以满足常用开发需求。

安装

  • 通过go get 安装
    go get -u -v github.com/gin-gonic/gin
  • 通过go mod 安装
    go mod init test

    程序引入即可,然后go run就会自动安装包依赖

使用demo

package main

import "github.com/gin-gonic/gin"

func main() {
    r := gin.Default()
    r.GET("/ping", func(c *gin.Context) {
        c.JSON(200, gin.H{
            "message": "pong",
        })
    })
    r.Run() // listen and serve on 0.0.0.0:8080
}

注意事项

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!

7条评论
  • Acousty

    2022年9月2日 01:38

    cialis generic name The Removal of Dr Eberl and the Re-Organisation of the Camp August 1942

  • Kebyecove

    2022年9月4日 07:00

    If you do not have insurance to pay for the drugs no prescription coverage or you risk falling into the Medicare doughnut hole priligy walgreens

  • dwerbus

    2022年9月6日 05:43

    best price for generic cialis Erectile dysfunction, also known as male impotence, is an extremely common condition that occurs when a man has difficulty getting and or keeping an erection

  • pacyImmaw

    2022年9月8日 07:49

    birkin bag answered 2 months ago where to buy cialis

  • ensuece

    2022年9月11日 05:08

    I m not for sure exactly when I O cause last month never got a full positive on the OPK but I do remember having the same crampy feeling for 2 days. buy clomid online from india 25mg Clomid sounds a little low, but I m sure your doc is just cautious conservative.

  • extedia

    2022年9月14日 07:51

    Steroid abuse is common across gyms across the world. 20 mg nolvadex pct

  • AnnoutFus

    2022年9月17日 22:38

    I like to avoid corneal transplantation or patch grafting in these patients because they can melt very quickly, but sometimes the perforation is so large, and you do all of these things like tarsorrhaphy or layered amniotic membrane, and you re forced to do it. 100mg of doxycycline

发表评论

您的电子邮箱地址不会被公开。