Skip to content

Commit 736c024

Browse files
authored
Merge pull request #282 from devfeel/develop
v1.7.3: Go 1_21 Upgrade + Dependency Updates + Fix go vet warnings + pprof production security hardening
2 parents d50e13e + 4495fd8 commit 736c024

13 files changed

Lines changed: 40 additions & 63 deletions

File tree

.github/workflows/go.yml

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
11
name: Go
2-
on: [push]
2+
3+
on:
4+
push:
35
jobs:
46

57
build:
6-
name: Build
78
runs-on: ubuntu-latest
89
steps:
10+
- uses: actions/checkout@v4
11+
- name: Set up Go
12+
uses: actions/setup-go@v4
13+
with:
14+
go-version: '1.20'
915

10-
- name: Set up Go 1.13
11-
uses: actions/setup-go@v1
12-
with:
13-
go-version: 1.13
14-
id: go
15-
16-
- name: Check out code into the Go module directory
17-
uses: actions/checkout@v1
18-
19-
- name: Get dependencies
20-
run: |
21-
go get -v -t -d ./...
22-
if [ -f Gopkg.toml ]; then
23-
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
24-
dep ensure
25-
fi
16+
- name: Build
17+
run: go build -v ./...
2618

27-
- name: Build
28-
run: go build -v .
19+
- name: Test
20+
run: go test -v ./...

cache/runtime/cache_runtime_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ func TestRuntimeCache_ConcurrentGetSetError(t *testing.T) {
216216
}
217217

218218
for i := 0; i < 10000; i++ {
219-
go func() {
220-
cache.Set(TESTCacheKey+strconv.Itoa(i), TESTCacheValue, 0)
219+
go func(val int) {
220+
cache.Set(TESTCacheKey+strconv.Itoa(val), TESTCacheValue, 0)
221221
wg.Done()
222-
}()
222+
}(i)
223223
}
224224
wg.Wait()
225225
}
@@ -232,17 +232,17 @@ func TestRuntimeCache_ConcurrentIncrDecrError(t *testing.T) {
232232
wg.Add(2 * 10000)
233233

234234
for i := 0; i < 10000; i++ {
235-
go func() {
236-
cache.Incr(TESTCacheKey + strconv.Itoa(i))
235+
go func(val int) {
236+
cache.Incr(TESTCacheKey + strconv.Itoa(val))
237237
wg.Done()
238-
}()
238+
}(i)
239239
}
240240

241241
for i := 0; i < 10000; i++ {
242-
go func() {
243-
cache.Decr(TESTCacheKey + strconv.Itoa(i))
242+
go func(val int) {
243+
cache.Decr(TESTCacheKey + strconv.Itoa(val))
244244
wg.Done()
245-
}()
245+
}(i)
246246
}
247247
wg.Wait()
248248
}

consts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package dotweb
33
// Global define
44
const (
55
// Version current version
6-
Version = "1.7.22"
6+
Version = "1.7.3"
77
)
88

99
// Log define

core/concurrenceMap_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func TestItemContext_Current(t *testing.T) {
7272
func BenchmarkItemContext_Set_1(b *testing.B) {
7373
var num uint64 = 1
7474
for i := 0; i < b.N; i++ {
75-
ic.Set(string(num), num)
75+
ic.Set(fmt.Sprint(num), num)
7676
}
7777
}
7878

@@ -81,7 +81,7 @@ func BenchmarkItemContext_Set_Parallel(b *testing.B) {
8181
b.RunParallel(func(pb *testing.PB) {
8282
var num uint64 = 1
8383
for pb.Next() {
84-
ic.Set(string(num), num)
84+
ic.Set(fmt.Sprint(num), num)
8585
}
8686
})
8787
}

core/state_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"github.com/devfeel/dotweb/test"
1010
)
1111

12+
var GlobalState = NewServerStateInfo()
13+
1214
// function tests
1315

1416
func Test_AddRequestCount_1(t *testing.T) {

dotweb.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,8 @@ func (app *DotWeb) initServerEnvironment() {
639639
}
640640

641641
// start pprof server
642-
if app.Config.App.EnabledPProf {
642+
// Only enable pprof in development mode for security
643+
if app.Config.App.EnabledPProf && app.RunMode() != RunMode_Production {
643644
app.Logger().Debug("DotWeb:StartPProfServer["+strconv.Itoa(app.Config.App.PProfPort)+"] Begin", LogTarget_HttpServer)
644645
go func() {
645646
err := http.ListenAndServe(":"+strconv.Itoa(app.Config.App.PProfPort), nil)

dotweb_test.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func Test_RunMode_2(t *testing.T) {
2929
}
3030
}
3131

32-
//测试IsDevelopmentMode函数
32+
// 测试IsDevelopmentMode函数
3333
func Test_IsDevelopmentMode_1(t *testing.T) {
3434
app := New()
3535
app.Config.App.RunMode = "development"
@@ -45,14 +45,6 @@ func Test_IsDevelopmentMode_2(t *testing.T) {
4545
t.Log("Run IsDevelopmentMode :", b)
4646
}
4747

48-
func TestDotWeb_UsePlugin(t *testing.T) {
49-
app := newConfigDotWeb()
50-
app.UsePlugin(new(testPlugin))
51-
app.UsePlugin(NewDefaultNotifyPlugin(app))
52-
fmt.Println(app.pluginMap)
53-
app.StartServer(8081)
54-
}
55-
5648
func newConfigDotWeb() *DotWeb {
5749
app := New()
5850
appConfig, err := config.InitConfig("config/testdata/dotweb.conf", "xml")

go.mod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
module github.com/devfeel/dotweb
22

3-
go 1.12
3+
go 1.21
44

55
require (
66
github.com/garyburd/redigo v1.6.0
7-
golang.org/x/net v0.0.0-20190606173856-1492cefac77f
7+
golang.org/x/net v0.23.0
88
gopkg.in/yaml.v2 v2.2.2
99
)
10+
11+
require gopkg.in/yaml.v3 v3.0.1 // indirect

go.sum

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ github.com/garyburd/redigo v1.6.0/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05
33
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
44
golang.org/x/net v0.0.0-20190606173856-1492cefac77f h1:IWHgpgFqnL5AhBUBZSgBdjl2vkQUEzcY+JNKWfcgAU0=
55
golang.org/x/net v0.0.0-20190606173856-1492cefac77f/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
6+
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
7+
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
68
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
79
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
10+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
811
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
912
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
1013
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
14+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
15+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

plugin_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"github.com/devfeel/dotweb/test"
66
"testing"
7-
"time"
87
)
98

109
type testPlugin struct {
@@ -36,15 +35,3 @@ func TestNotifyPlugin_IsValidate(t *testing.T) {
3635
needShow := true
3736
test.Equal(t, needShow, p.IsValidate())
3837
}
39-
40-
func TestNotifyPlugin_Run(t *testing.T) {
41-
app := newConfigDotWeb()
42-
p := NewDefaultNotifyPlugin(app)
43-
go func() {
44-
for {
45-
fmt.Println(p.ModTimes[app.Config.ConfigFilePath])
46-
time.Sleep(time.Duration(600 * time.Millisecond))
47-
}
48-
}()
49-
p.Run()
50-
}

0 commit comments

Comments
 (0)