Go的学习旅程7:Web的实现以及beego的

1.原生的hello,world

运行时候输入go run xxx.go就可以通过浏览器访问:127.0.0.1:888

package main

import (
   "fmt"
   "net/http"
   "log"
)

func handler(w http.ResponseWriter, r *http.Request) {
   fmt.Fprintf(w, "Hello world!") //这个写入到w的是输出到客户端的
}


func main() {
   //设置访问的路由
   http.HandleFunc("/", handler)
   //设置监听的端口
   err := http.ListenAndServe(":888", nil)
   if err != nil {
      log.Fatal("ListenAndServe: ", err)
   }
}


2.beego框架的使用

   
     2.1beego和bee的安装

  

      文档位置:https://beego.me/quickstart,需要注意,如果bee提示:

      


1212121212121212

猜你喜欢

转载自blog.csdn.net/feiwutudou/article/details/80507621