I'm a new user converting an application to Go. I have something like the following which is working:
type Network struct {
Ssid string
Security string
Bitrate string
}
func Scan(w http.ResponseWriter, r *http.Request) {
output := runcmd(scripts+"scan.sh", true)
bytes := []byte(output)
var networks []Network
json.Unmarshal(bytes, &networks)
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(networks)
}
The problem is the old version didn't use capitals on the json variables returned.
I want the front-end to see ssid
not Ssid
. If I make the attributes in the struct lowercase the code no longer works as they become unexported variables.