|
@@ -1,24 +1,24 @@
|
|
package main
|
|
package main
|
|
|
|
|
|
import (
|
|
import (
|
|
- "net/http";
|
|
|
|
- "encoding/json";
|
|
|
|
- "runtime";
|
|
|
|
- "fmt";
|
|
|
|
|
|
+ "encoding/json"
|
|
|
|
+ "fmt"
|
|
|
|
+ "net/http"
|
|
|
|
+ "runtime"
|
|
)
|
|
)
|
|
|
|
|
|
type MessageStruct struct {
|
|
type MessageStruct struct {
|
|
- Message string
|
|
|
|
|
|
+ Message string
|
|
}
|
|
}
|
|
|
|
|
|
func hello(w http.ResponseWriter, r *http.Request) {
|
|
func hello(w http.ResponseWriter, r *http.Request) {
|
|
- m := MessageStruct{"Hello, world"}
|
|
|
|
- enc := json.NewEncoder(w)
|
|
|
|
- enc.Encode(m)
|
|
|
|
|
|
+ m := MessageStruct{"Hello, world"}
|
|
|
|
+ enc := json.NewEncoder(w)
|
|
|
|
+ enc.Encode(m)
|
|
}
|
|
}
|
|
|
|
|
|
func main() {
|
|
func main() {
|
|
- runtime.GOMAXPROCS(runtime.NumCPU())
|
|
|
|
- http.HandleFunc("/json", hello)
|
|
|
|
- http.ListenAndServe(":8080", nil)
|
|
|
|
|
|
+ runtime.GOMAXPROCS(runtime.NumCPU())
|
|
|
|
+ http.HandleFunc("/json", hello)
|
|
|
|
+ http.ListenAndServe(":8080", nil)
|
|
}
|
|
}
|