-
Notifications
You must be signed in to change notification settings - Fork 0
/
basics.go
80 lines (66 loc) · 1.38 KB
/
basics.go
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package main
import (
"fmt"
"http"
)
func add( x ,y int) int{
return x + y;
}
func split(sum int) (x, y int) {
x = sum * 4 / 9
y = sum - x
return
}
var x, y, z int = 1, 2, 3
var c, python, java = true, false, "no!"
func array_logic(){
p := []int{2, 3, 5, 7, 11, 13}
fmt.Println("p ==", p)
for i := 0; i < len(p); i++ {
fmt.Printf("p[%d] == %d\n",
i, p[i])
}
}
func main(){
i := 1;
http_main()
for {
// fmt.Printf("hello, world\n");
add(4,5)
split(17)
array_logic()
if i % 10000000 == 0{
fmt.Println(i/10000000,x,y,z,c,python,java);
}
i++
}
}
func http_main(){
//Process the http commands
fmt.Printf("Starting http Server ... ")
http.Handle("/", http.HandlerFunc(sayHello))
err := http.ListenAndServe("0.0.0.0:8080", nil)
if err != nil {
fmt.Printf("ListenAndServe Error",err)
}
}
func sayHello(c http.ResponseWriter, req *http.Request) {
fmt.Printf("New Request\n")
processRequest(c, req)
}
func processRequest(w http.ResponseWriter, req *http.Request){
time.Sleep(time.Second*3)
w.Write([]byte("Go Say’s Hello(Via http)"))
fmt.Println("End")
}
type Vertex struct {
Lat, Long float64
}
var m = map[string]Vertex{
"Bell Labs": Vertex{
40.68433, -74.39967,
},
"Google": Vertex{
37.42202, -122.08408,
},
}