LMLPHP后院

Golang 报错记录技术

maybe yes 发表于 2021-09-04 11:33

golang 学习记录,代码记录,报错记录

使用 gin net/http 创建一个 web 服务

_ := http.ListenAndServe(":9090", nil) // 不需要冒号
./gin1.go:14:4: no new variables on left side of :=
package main

import (
        "fmt"
        "net/http"
)

func sayHello (w http.ResponseWriter, r *http.Request) {
        _, _ = fmt.Fprintln(w, "Hello")
}

func main () {
        http.HandleFunc("/hello", sayHello)
        _ = http.ListenAndServe(":9090", nil)
}
2024-05-02 05:55:58 1714600558 0.020442