Go语言程序错误

Go语言程序错误,go,Go,我是一个新的围棋语言程序员。下面是我的程序,但我遇到了此错误: #command-line-arguments .\helloworld.go:20: undefined: json.Marshall 有人能告诉我为什么会出错吗 package main import ( "encoding/json" "fmt" "net/http" ) type API struct { Message string "json:message" } func

我是一个新的围棋语言程序员。下面是我的程序,但我遇到了此错误:

#command-line-arguments
    .\helloworld.go:20: undefined: json.Marshall
有人能告诉我为什么会出错吗

package main

import (
    "encoding/json"
    "fmt"
    "net/http"
)

type API struct {
    Message string "json:message"
}

func main() {

    http.HandleFunc("/api", func(w http.ResponseWriter, r *http.Request) {

        message := API{"Hello, World!!!"}

        output, err := json.Marshall(message)

        if err != nil {
            fmt.Println("Something went wrong")
        }

        fmt.Fprintf(w, string(output))

    })

    http.ListenAndServe(":8080", nil)

}
更新你的程序

output, err := json.Marshal(message)

Marshal
与一个
l
,)。

输出清楚地告诉您问题所在

未定义:json.Marshall

表示没有具有此名称的方法。另一方面,查看调用的方法

func封送处理(v接口{})([]字节,错误)


因此,只需使用正确的名称并学习如何调试,因为调试在软件工程中非常重要。

我不是专家,但快速查看API就会发现该函数是Marshal(一个“l”,而不是两个)。