package main import ( "database/sql" "encoding/json" "fmt" "net/http" _ "github.com/go-sql-driver/mysql" ) type User struct { Name string `json:"name"` Email string `json:"email"` ID int `json:"int"` } func userRouter(w http.ResponseWriter, r *http.Request) { ourUser := User{ Name: "Bill Smith", Email: "bill.smith@example.com", ID: 100, } output, _ := json.Marshal(&ourUser) fmt.Fprint(w, string(output)) } var database *sql.DB func main() { fmt.Println("Starting JSON server") http.HandleFunc("/user", userRouter) http.ListenAndServe(":8080", nil) }