feat: init update

This commit is contained in:
2026-01-02 17:04:48 +08:00
commit a92b4daaf4
5 changed files with 41 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*.exe
*.prof

3
go.mod Normal file
View File

@@ -0,0 +1,3 @@
module k8s-example
go 1.25.5

9
hello/hello.go Normal file
View File

@@ -0,0 +1,9 @@
package hello
import (
"net/http"
)
func HelloHandler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello, World!"))
}

16
hello/hello_test.go Normal file
View File

@@ -0,0 +1,16 @@
package hello
import (
"testing"
"net/http/httptest"
)
func TestHelloHandler(t *testing.T) {
w := httptest.NewRecorder()
req := httptest.NewRequest("GET", "/hello", nil)
HelloHandler(w, req)
expected := "Hello, World!"
if w.Body.String() != expected {
t.Errorf("Expected %q but got %q", expected, w.Body.String())
}
}

11
main.go Normal file
View File

@@ -0,0 +1,11 @@
package main
import (
"net/http"
"k8s-example/hello"
)
func main() {
http.HandleFunc("/hello", hello.HelloHandler)
http.ListenAndServe(":8800", nil)
}