• 安装echo框架


    视频地址:

    https://www.bilibili.com/video/av63492462?p=31

    echo文档地址:

    https://echo.labstack.com/guide/installation

    下载echo框架

    在项目根目录里(D:Gowwwsrcecho_one) 建新 main.go

    package main
    
    import (
       "net/http"
       "github.com/labstack/echo"
    )
    
    func main() {
       e := echo.New()
       e.GET("/", func(c echo.Context) error {
          return c.String(http.StatusOK, "Hello, World!")
       })
       e.Logger.Fatal(e.Start(":8001"))
    }
    

    在cmd里,cd到项目根目录里

    D:Gowwwsrcecho_one>set GO111MODULE=on
    D:Gowwwsrcecho_one>go mod init
    D:Gowwwsrcecho_one>go mod tidy
    

    D:Gowwwsrcecho_onego.mod里

    module echo_one
    
    go 1.12
    
    require (
       github.com/labstack/echo v3.3.10+incompatible
       github.com/labstack/gommon v0.3.0 // indirect
       golang.org/x/crypto v0.0.0-20191108234033-bd318be0434a // indirect
    )
    
    replace golang.org/x/crypto v0.0.0-20191108234033-bd318be0434a => github.com/golang/crypto v0.0.0-20191108234033-bd318be0434a // indirect
    

    再cmd里再执行命令

    D:Gowwwsrcecho_one>go mod download
    

    此时已经安装好echo了

    cmd里启动运行一下

    D:Gowwwsrcecho_one>go run main.go
    
       ____    __
      / __/___/ /  ___
     / _// __/ _ / _ 
    /___/\__/_//_/\___/ v3.3.10-dev
    High performance, minimalist Go web framework
    https://echo.labstack.com
    ____________________________________O/_______
                                        O
    ⇨ http server started on [::]:8001
    

    或者:

    D:Gowwwsrcecho_one>bee run
    ______
    | ___ 
    | |_/ /  ___   ___
    | ___  / _  / _ 
    | |_/ /|  __/|  __/
    \____/  \___| \___| v1.10.0
    2019/11/10 19:44:12 INFO     ▶ 0001 Using 'echo_one' as 'appname'
    2019/11/10 19:44:12 INFO     ▶ 0002 Initializing watcher...
    2019/11/10 19:44:19 SUCCESS  ▶ 0003 Built Successfully!
    2019/11/10 19:44:19 INFO     ▶ 0004 Restarting 'echo_one.exe'...
    2019/11/10 19:44:19 SUCCESS  ▶ 0005 './echo_one.exe' is running...
    
       ____    __
      / __/___/ /  ___
     / _// __/ _ / _ 
    /___/\__/_//_/\___/ v3.3.10-dev
    High performance, minimalist Go web framework
    https://echo.labstack.com
    ____________________________________O/_______
                                        O
    ⇨ http server started on [::]:8001
    
    
    

    访问一下

    http://localhost:8001/

    Hello, World!

  • 相关阅读:
    逻辑思维杂想
    C++二叉树实现
    斐波那数列递归实现与动态规划实现
    C++双向链表的实现
    C++单链表实现
    C++顺序表实现
    windows下端口占用处理工具
    [项目记录]一个.net下使用HAP实现的吉大校园通知网爬虫工具:OAWebScraping
    [c++]大数运算---利用C++ string实现任意长度正小数、整数之间的加减法
    [C++]几种排序
  • 原文地址:https://www.cnblogs.com/haima/p/11831486.html
Copyright © 2020-2023  润新知