feat: init update
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
*.exe
|
||||||
|
*.prof
|
||||||
9
hello/hello.go
Normal file
9
hello/hello.go
Normal 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
16
hello/hello_test.go
Normal 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())
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user