-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
44 lines (35 loc) · 756 Bytes
/
main.go
File metadata and controls
44 lines (35 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"fmt"
"log"
"net/http"
_ "net/http/pprof"
"regexp"
)
// TestType blah blah blah
type TestType struct {
id string `json:"id"`
name string `json:"name"`
}
func name(params) {
fmt.Println("")
}
func name(params) {}
func handler(w http.ResponseWriter, r *http.Request) {
re := regexp.MustCompile("^*(.+)@golang.org$")
path := r.URL.Path[1:]
match := re.FindAllStringSubmatch(path, -1)
if match != nil {
fmt.Fprintf(w, "Hello gopher %s\n", match[0][1])
return
}
fmt.Fprintf(w, "Hello dear %s\n", path)
}
func main() {
http.HandleFunc("/", handler)
fmt.Println("Listening on http://localhost:3000/")
err := http.ListenAndServe("localhost:3000", nil)
if err != nil {
log.Fatal("ListenAndServe:", err)
}
}