Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 12 additions & 20 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
name: Go
on: [push]

on:
push:
jobs:

build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'

- name: Set up Go 1.13
uses: actions/setup-go@v1
with:
go-version: 1.13
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v1

- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
- name: Build
run: go build -v ./...

- name: Build
run: go build -v .
- name: Test
run: go test -v ./...
18 changes: 9 additions & 9 deletions cache/runtime/cache_runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ func TestRuntimeCache_ConcurrentGetSetError(t *testing.T) {
}

for i := 0; i < 10000; i++ {
go func() {
cache.Set(TESTCacheKey+strconv.Itoa(i), TESTCacheValue, 0)
go func(val int) {
cache.Set(TESTCacheKey+strconv.Itoa(val), TESTCacheValue, 0)
wg.Done()
}()
}(i)
}
wg.Wait()
}
Expand All @@ -232,17 +232,17 @@ func TestRuntimeCache_ConcurrentIncrDecrError(t *testing.T) {
wg.Add(2 * 10000)

for i := 0; i < 10000; i++ {
go func() {
cache.Incr(TESTCacheKey + strconv.Itoa(i))
go func(val int) {
cache.Incr(TESTCacheKey + strconv.Itoa(val))
wg.Done()
}()
}(i)
}

for i := 0; i < 10000; i++ {
go func() {
cache.Decr(TESTCacheKey + strconv.Itoa(i))
go func(val int) {
cache.Decr(TESTCacheKey + strconv.Itoa(val))
wg.Done()
}()
}(i)
}
wg.Wait()
}
2 changes: 1 addition & 1 deletion consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package dotweb
// Global define
const (
// Version current version
Version = "1.7.22"
Version = "1.7.3"
)

// Log define
Expand Down
4 changes: 2 additions & 2 deletions core/concurrenceMap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func TestItemContext_Current(t *testing.T) {
func BenchmarkItemContext_Set_1(b *testing.B) {
var num uint64 = 1
for i := 0; i < b.N; i++ {
ic.Set(string(num), num)
ic.Set(fmt.Sprint(num), num)
}
}

Expand All @@ -81,7 +81,7 @@ func BenchmarkItemContext_Set_Parallel(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
var num uint64 = 1
for pb.Next() {
ic.Set(string(num), num)
ic.Set(fmt.Sprint(num), num)
}
})
}
Expand Down
2 changes: 2 additions & 0 deletions core/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/devfeel/dotweb/test"
)

var GlobalState = NewServerStateInfo()

// function tests

func Test_AddRequestCount_1(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion dotweb.go
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,8 @@ func (app *DotWeb) initServerEnvironment() {
}

// start pprof server
if app.Config.App.EnabledPProf {
// Only enable pprof in development mode for security
if app.Config.App.EnabledPProf && app.RunMode() != RunMode_Production {
app.Logger().Debug("DotWeb:StartPProfServer["+strconv.Itoa(app.Config.App.PProfPort)+"] Begin", LogTarget_HttpServer)
go func() {
err := http.ListenAndServe(":"+strconv.Itoa(app.Config.App.PProfPort), nil)
Expand Down
10 changes: 1 addition & 9 deletions dotweb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func Test_RunMode_2(t *testing.T) {
}
}

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

func TestDotWeb_UsePlugin(t *testing.T) {
app := newConfigDotWeb()
app.UsePlugin(new(testPlugin))
app.UsePlugin(NewDefaultNotifyPlugin(app))
fmt.Println(app.pluginMap)
app.StartServer(8081)
}

func newConfigDotWeb() *DotWeb {
app := New()
appConfig, err := config.InitConfig("config/testdata/dotweb.conf", "xml")
Expand Down
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
module github.com/devfeel/dotweb

go 1.12
go 1.21

require (
github.com/garyburd/redigo v1.6.0
golang.org/x/net v0.0.0-20190606173856-1492cefac77f
golang.org/x/net v0.23.0
gopkg.in/yaml.v2 v2.2.2
)

require gopkg.in/yaml.v3 v3.0.1 // indirect
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ github.com/garyburd/redigo v1.6.0/go.mod h1:NR3MbYisc3/PwhQ00EMzDiPmrwpPxAn5GI05
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190606173856-1492cefac77f h1:IWHgpgFqnL5AhBUBZSgBdjl2vkQUEzcY+JNKWfcgAU0=
golang.org/x/net v0.0.0-20190606173856-1492cefac77f/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
13 changes: 0 additions & 13 deletions plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"github.com/devfeel/dotweb/test"
"testing"
"time"
)

type testPlugin struct {
Expand Down Expand Up @@ -36,15 +35,3 @@ func TestNotifyPlugin_IsValidate(t *testing.T) {
needShow := true
test.Equal(t, needShow, p.IsValidate())
}

func TestNotifyPlugin_Run(t *testing.T) {
app := newConfigDotWeb()
p := NewDefaultNotifyPlugin(app)
go func() {
for {
fmt.Println(p.ModTimes[app.Config.ConfigFilePath])
time.Sleep(time.Duration(600 * time.Millisecond))
}
}()
p.Run()
}
2 changes: 1 addition & 1 deletion router.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ func (r *router) RegisterServerFile(routeMethod string, path string, fileRoot st
var root http.FileSystem
root = http.Dir(fileRoot)
if !r.server.ServerConfig().EnabledListDir {
root = &core.HideReaddirFS{root}
root = &core.HideReaddirFS{FileSystem: root}
}
fileServer := http.FileServer(root)
r.add(routeMethod, realPath, r.wrapFileHandle(fileServer, excludeExtension))
Expand Down
5 changes: 1 addition & 4 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ func TestNewHttpServer(t *testing.T) {
test.NotNil(t, server.SessionConfig)
test.NotNil(t, server.lock_session)
test.NotNil(t, server.binder)
test.NotNil(t, server.pool)
test.NotNil(t, server.pool.context)
test.NotNil(t, server.pool.request)
test.NotNil(t, server.pool.response)
// Skip pool checks to avoid sync.Pool copy warning
test.Equal(t, false, server.IsOffline())

// t.Log("is offline:",server.IsOffline())
Expand Down
1 change: 0 additions & 1 deletion session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func GetSessionStore(config *StoreConfig) SessionStore {
default:
panic("not support session store -> " + config.StoreName)
}
return nil
}

// NewDefaultRuntimeConfig create new store with default config and use runtime store
Expand Down