1.新建项目与项目文件
2.编写代码
package main
import (
"fmt"
"net/http"
)
func sayHello(w http.ResponseWriter, r *http.Request) {
_, _ = fmt.Fprintf(w, "Hello Golang")
}
func main() {
http.HandleFunc("/hello", sayHello)
err := http.ListenAndServe(":9090", nil)
if err != nil {
fmt.Printf("http serve failed,err:%v\n", err)
return
}
}
3.运行文件
4.测试