style: 格式化代码
- 使用 Go 1.13+ 八进制字面量格式 (0o644) - 修复文件末尾缺少换行符 - 对齐结构体字段 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
1f672d1a7a
commit
c18ce613b3
@ -24,17 +24,17 @@ import (
|
|||||||
|
|
||||||
// App manages the server lifecycle (Windows version).
|
// App manages the server lifecycle (Windows version).
|
||||||
type App struct {
|
type App struct {
|
||||||
resv resolver.Resolver
|
resv resolver.Resolver
|
||||||
cfg *config.Config
|
cfg *config.Config
|
||||||
srv *server.Server
|
srv *server.Server
|
||||||
http3Srv *http3.Server
|
http3Srv *http3.Server
|
||||||
http2Srv *http2.Server
|
http2Srv *http2.Server
|
||||||
streamSrv *stream.Server
|
streamSrv *stream.Server
|
||||||
logger *logging.AppLogger
|
logger *logging.AppLogger
|
||||||
cfgPath string
|
cfgPath string
|
||||||
pidFile string
|
pidFile string
|
||||||
logFile string
|
logFile string
|
||||||
listeners []net.Listener
|
listeners []net.Listener
|
||||||
upgradeMgr *server.UpgradeManager
|
upgradeMgr *server.UpgradeManager
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -747,10 +747,10 @@ http {
|
|||||||
|
|
||||||
func TestConvertProxyRedirect(t *testing.T) {
|
func TestConvertProxyRedirect(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
input string
|
input string
|
||||||
mode string
|
mode string
|
||||||
rules int
|
rules int
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "off",
|
name: "off",
|
||||||
@ -956,9 +956,9 @@ http {
|
|||||||
|
|
||||||
func TestConvertUpstreamLoadBalance(t *testing.T) {
|
func TestConvertUpstreamLoadBalance(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
upstream string
|
upstream string
|
||||||
wantLB string
|
wantLB string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "least_conn",
|
name: "least_conn",
|
||||||
@ -1325,4 +1325,3 @@ http {
|
|||||||
t.Errorf("Listen = %s, want 0.0.0.0:80 when no listen directive", s.Listen)
|
t.Errorf("Listen = %s, want 0.0.0.0:80 when no listen directive", s.Listen)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -193,7 +193,7 @@ func TestParseFile(t *testing.T) {
|
|||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
path := filepath.Join(dir, "nginx.conf")
|
path := filepath.Join(dir, "nginx.conf")
|
||||||
content := "listen 80;\nserver_name example.com;"
|
content := "listen 80;\nserver_name example.com;"
|
||||||
if err := os.WriteFile(path, []byte(content), 0644); err != nil {
|
if err := os.WriteFile(path, []byte(content), 0o644); err != nil {
|
||||||
t.Fatalf("write file: %v", err)
|
t.Fatalf("write file: %v", err)
|
||||||
}
|
}
|
||||||
cfg, err := ParseFile(path)
|
cfg, err := ParseFile(path)
|
||||||
@ -216,21 +216,21 @@ func TestParseIncludeGlob(t *testing.T) {
|
|||||||
|
|
||||||
// Create a subdirectory for included files to avoid matching nginx.conf itself.
|
// Create a subdirectory for included files to avoid matching nginx.conf itself.
|
||||||
incDir := filepath.Join(dir, "includes")
|
incDir := filepath.Join(dir, "includes")
|
||||||
if err := os.Mkdir(incDir, 0755); err != nil {
|
if err := os.Mkdir(incDir, 0o755); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.WriteFile(filepath.Join(incDir, "a.conf"), []byte("listen 80;\n"), 0644); err != nil {
|
if err := os.WriteFile(filepath.Join(incDir, "a.conf"), []byte("listen 80;\n"), 0o644); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := os.WriteFile(filepath.Join(incDir, "b.conf"), []byte("server_name a.com;\n"), 0644); err != nil {
|
if err := os.WriteFile(filepath.Join(incDir, "b.conf"), []byte("server_name a.com;\n"), 0o644); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create main config with include.
|
// Create main config with include.
|
||||||
main := filepath.Join(dir, "nginx.conf")
|
main := filepath.Join(dir, "nginx.conf")
|
||||||
content := "include " + incDir + "/*.conf;"
|
content := "include " + incDir + "/*.conf;"
|
||||||
if err := os.WriteFile(main, []byte(content), 0644); err != nil {
|
if err := os.WriteFile(main, []byte(content), 0o644); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,10 +256,10 @@ func TestParseIncludeCircular(t *testing.T) {
|
|||||||
a := filepath.Join(dir, "a.conf")
|
a := filepath.Join(dir, "a.conf")
|
||||||
b := filepath.Join(dir, "b.conf")
|
b := filepath.Join(dir, "b.conf")
|
||||||
|
|
||||||
if err := os.WriteFile(a, []byte("include "+b+";"), 0644); err != nil {
|
if err := os.WriteFile(a, []byte("include "+b+";"), 0o644); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if err := os.WriteFile(b, []byte("include "+a+";"), 0644); err != nil {
|
if err := os.WriteFile(b, []byte("include "+a+";"), 0o644); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -289,7 +289,7 @@ func TestParseIncludeMaxDepth(t *testing.T) {
|
|||||||
} else {
|
} else {
|
||||||
content = "listen 80;"
|
content = "listen 80;"
|
||||||
}
|
}
|
||||||
if err := os.WriteFile(path, []byte(content), 0644); err != nil {
|
if err := os.WriteFile(path, []byte(content), 0o644); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -307,7 +307,7 @@ func TestParseIncludeNotFound(t *testing.T) {
|
|||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
main := filepath.Join(dir, "nginx.conf")
|
main := filepath.Join(dir, "nginx.conf")
|
||||||
content := "include /nonexistent/path.conf;"
|
content := "include /nonexistent/path.conf;"
|
||||||
if err := os.WriteFile(main, []byte(content), 0644); err != nil {
|
if err := os.WriteFile(main, []byte(content), 0o644); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
_, err := ParseFile(main)
|
_, err := ParseFile(main)
|
||||||
@ -320,7 +320,7 @@ func TestParseIncludeGlobNoMatch(t *testing.T) {
|
|||||||
dir := t.TempDir()
|
dir := t.TempDir()
|
||||||
main := filepath.Join(dir, "nginx.conf")
|
main := filepath.Join(dir, "nginx.conf")
|
||||||
content := "include " + dir + "/nonexistent/*.conf;"
|
content := "include " + dir + "/nonexistent/*.conf;"
|
||||||
if err := os.WriteFile(main, []byte(content), 0644); err != nil {
|
if err := os.WriteFile(main, []byte(content), 0o644); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
cfg, err := ParseFile(main)
|
cfg, err := ParseFile(main)
|
||||||
@ -334,10 +334,10 @@ func TestParseIncludeGlobNoMatch(t *testing.T) {
|
|||||||
|
|
||||||
func TestParseLocationModifiers(t *testing.T) {
|
func TestParseLocationModifiers(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
input string
|
input string
|
||||||
dirName string
|
dirName string
|
||||||
args []string
|
args []string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "exact match",
|
name: "exact match",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user