视频地址:
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
访问一下
Hello, World!