소스 검색

my horrible go function

Алексей 2 년 전
커밋
295bf77bdf
1개의 변경된 파일27개의 추가작업 그리고 0개의 파일을 삭제
  1. 27 0
      main.go

+ 27 - 0
main.go

@@ -0,0 +1,27 @@
+package main
+
+import (
+    "fmt"
+    "net/http"
+	"log"
+)
+func main() {
+	http.HandleFunc("/", sayhello) // Устанавливаем роутер
+	http.HandleFunc("/home", sayhello1)
+	http.HandleFunc("/omegalul", sayhello2)
+	err := http.ListenAndServe(":8080", nil) // устанавливаем порт веб-сервера
+	if err != nil {
+		log.Fatal("ListenAndServe: ", err)
+	}
+	
+}
+func sayhello(w http.ResponseWriter, r *http.Request) {
+    fmt.Fprintf(w, "Привет!")
+}
+func sayhello1(w http.ResponseWriter, r *http.Request) {
+    fmt.Fprintf(w, "darova ept eto home!")
+}
+func sayhello2(w http.ResponseWriter, r *http.Request) {
+    fmt.Fprintf(w, "kekwait")
+}
+