summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-12-03 14:47:01 +0800
committerEltrac <hi@guhub.cn>2025-12-03 14:47:01 +0800
commitc1f6161d4360578cba00f2a6933b7cf9247622a3 (patch)
treeb907b66e0beb5da85f3f8b83cb871ef40188bd5d
parent8871615c98bce3c2c3aa871ce4e80126558cb91b (diff)
style: run gofmt and remove pointless comments
-rw-r--r--context.go22
-rw-r--r--engine.go2
-rw-r--r--group.go4
-rw-r--r--group_test.go42
-rw-r--r--parser_test.go2
5 files changed, 27 insertions, 45 deletions
diff --git a/context.go b/context.go
index e0de660..6241179 100644
--- a/context.go
+++ b/context.go
@@ -44,9 +44,9 @@ func (c *Context) XML(code int, data string) {
// error, message, status
func (c *Context) Error(code int, msg string) {
c.JSON(code, map[string]string{
- "error": http.StatusText(code),
+ "error": http.StatusText(code),
"message": msg,
- "status": strconv.Itoa(code),
+ "status": strconv.Itoa(code),
})
}
@@ -101,13 +101,13 @@ func (c *Context) SetCompleteCookie(cookie *http.Cookie) {
func (c *Context) SetCookie(name string, value string) {
cookie := http.Cookie{
- Name: name,
- Value: value,
- Path: "/",
- MaxAge: 3600,
- HttpOnly: true,
- Secure: true,
- SameSite: http.SameSiteLaxMode,
- }
- c.SetCompleteCookie(&cookie)
+ Name: name,
+ Value: value,
+ Path: "/",
+ MaxAge: 3600,
+ HttpOnly: true,
+ Secure: true,
+ SameSite: http.SameSiteLaxMode,
+ }
+ c.SetCompleteCookie(&cookie)
}
diff --git a/engine.go b/engine.go
index f777e6d..4c19fb2 100644
--- a/engine.go
+++ b/engine.go
@@ -42,7 +42,7 @@ func (a *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request) {
W: w,
R: req,
Params: params,
- Querys: query,
+ Querys: query,
})
}
diff --git a/group.go b/group.go
index 06370eb..c08e3a2 100644
--- a/group.go
+++ b/group.go
@@ -20,8 +20,8 @@ func (e *Engine) Group(prefix string, fn func(*Group)) {
// Group.Group creates a nested Group
// joining all prefixes of parent groups
-func(g *Group) Group(prefix string, fn func(*Group)) {
- nested := &Group {
+func (g *Group) Group(prefix string, fn func(*Group)) {
+ nested := &Group{
prefix: joinPath(g.prefix, prefix),
engine: g.engine,
}
diff --git a/group_test.go b/group_test.go
index e682f09..e1ceca4 100644
--- a/group_test.go
+++ b/group_test.go
@@ -6,12 +6,6 @@ import (
"testing"
)
-/*
- ======================================================
- Test Group()
- ======================================================
-*/
-
func TestGroupCallback(t *testing.T) {
e := New()
@@ -32,12 +26,6 @@ func TestGroupCallback(t *testing.T) {
}
}
-/*
- ======================================================
- Test route registration
- ======================================================
-*/
-
func TestGroupRouteRegistration(t *testing.T) {
e := New()
@@ -81,24 +69,6 @@ func TestGroupRouteRegistration(t *testing.T) {
}
}
-// helper: convert []string{"api","ping"} → "api/ping"
-func joinParts(parts []string) string {
- out := ""
- for i, p := range parts {
- if i > 0 {
- out += "/"
- }
- out += p
- }
- return out
-}
-
-/*
- ======================================================
- End-to-End ServeHTTP test
- ======================================================
-*/
-
func TestGroupServeHTTP(t *testing.T) {
e := New()
@@ -121,3 +91,15 @@ func TestGroupServeHTTP(t *testing.T) {
t.Fatalf("expected body 'ok', got '%s'", body)
}
}
+
+// helper: convert []string{"api","ping"} → "api/ping"
+func joinParts(parts []string) string {
+ out := ""
+ for i, p := range parts {
+ if i > 0 {
+ out += "/"
+ }
+ out += p
+ }
+ return out
+}
diff --git a/parser_test.go b/parser_test.go
index c63f758..cf00017 100644
--- a/parser_test.go
+++ b/parser_test.go
@@ -34,7 +34,7 @@ func TestRouterSplitPath(t *testing.T) {
func TestExtractQueryStr(t *testing.T) {
tests := []struct {
input string
- want1 string
+ want1 string
want2 string
}{
{"", "", ""},