go1.8
How come the following always rund in the background? I have named the file server.go and is doing "go run server.go
"
package main
import (
"fmt"
"net/http"
)
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hi there X, I love %s!", r.URL.Path[1:])
}
func main() {
http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)
}
VS Code Launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${workspaceRoot}",
"env": {},
"args": [],
"showLog": true
}
]
}
Update: I get this error in VS Code Terminal:
2017/04/07 16:41:41 debugger.go:257: created breakpoint: &api.Breakpoint{ID:1, Name:"", Addr:0x12063ef, File:"/Users/X/Documents/X/play/go/server.go", Line:9, FunctionName:"main.handler", Cond:"", Tracepoint:false, Goroutine:false, Stacktrace:0, Variables:[]string(nil), LoadArgs:(*api.LoadConfig)(nil), LoadLocals:(*api.LoadConfig)(nil), HitCount:map[string]uint64{}, TotalHitCount:0x0}
2017/04/07 16:41:41 debugger.go:412: continuing