mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-18 14:39:49 +02:00
refactor: move task, error and testing utils to separte repo; apply gofumpt
This commit is contained in:
@@ -9,12 +9,12 @@ import (
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/rs/zerolog/log"
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
maxmind "github.com/yusing/godoxy/internal/maxmind/types"
|
||||
"github.com/yusing/godoxy/internal/task"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
ioutils "github.com/yusing/goutils/io"
|
||||
strutils "github.com/yusing/goutils/strings"
|
||||
"github.com/yusing/goutils/synk"
|
||||
"github.com/yusing/goutils/task"
|
||||
"golang.org/x/time/rate"
|
||||
)
|
||||
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
"time"
|
||||
|
||||
. "github.com/yusing/godoxy/internal/logging/accesslog"
|
||||
"github.com/yusing/godoxy/internal/task"
|
||||
"github.com/yusing/godoxy/internal/utils"
|
||||
expect "github.com/yusing/godoxy/internal/utils/testing"
|
||||
"github.com/yusing/goutils/task"
|
||||
expect "github.com/yusing/goutils/testing"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -9,9 +9,10 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/afero"
|
||||
"github.com/yusing/godoxy/internal/task"
|
||||
expect "github.com/yusing/godoxy/internal/utils/testing"
|
||||
expect "github.com/yusing/goutils/testing"
|
||||
|
||||
strutils "github.com/yusing/goutils/strings"
|
||||
"github.com/yusing/goutils/task"
|
||||
)
|
||||
|
||||
func TestBackScanner(t *testing.T) {
|
||||
|
||||
@@ -3,8 +3,8 @@ package accesslog
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
"github.com/yusing/godoxy/internal/serialization"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/yusing/godoxy/internal/docker"
|
||||
. "github.com/yusing/godoxy/internal/logging/accesslog"
|
||||
"github.com/yusing/godoxy/internal/serialization"
|
||||
expect "github.com/yusing/godoxy/internal/utils/testing"
|
||||
expect "github.com/yusing/goutils/testing"
|
||||
)
|
||||
|
||||
func TestNewConfig(t *testing.T) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
. "github.com/yusing/godoxy/internal/logging/accesslog"
|
||||
expect "github.com/yusing/godoxy/internal/utils/testing"
|
||||
expect "github.com/yusing/goutils/testing"
|
||||
)
|
||||
|
||||
// Cookie header should be removed,
|
||||
|
||||
@@ -6,9 +6,8 @@ import (
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
expect "github.com/yusing/godoxy/internal/utils/testing"
|
||||
|
||||
"github.com/yusing/godoxy/internal/task"
|
||||
"github.com/yusing/goutils/task"
|
||||
expect "github.com/yusing/goutils/testing"
|
||||
)
|
||||
|
||||
func TestConcurrentFileLoggersShareSameAccessLogIO(t *testing.T) {
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
nettypes "github.com/yusing/godoxy/internal/net/types"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
strutils "github.com/yusing/goutils/strings"
|
||||
)
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
|
||||
. "github.com/yusing/godoxy/internal/logging/accesslog"
|
||||
nettypes "github.com/yusing/godoxy/internal/net/types"
|
||||
expect "github.com/yusing/godoxy/internal/utils/testing"
|
||||
strutils "github.com/yusing/goutils/strings"
|
||||
expect "github.com/yusing/goutils/testing"
|
||||
)
|
||||
|
||||
func TestStatusCodeFilter(t *testing.T) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
strutils "github.com/yusing/goutils/strings"
|
||||
)
|
||||
|
||||
@@ -70,7 +70,7 @@ func (r *Retention) Parse(v string) (err error) {
|
||||
if !r.IsValid() {
|
||||
return ErrZeroValue
|
||||
}
|
||||
return
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *Retention) String() string {
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
. "github.com/yusing/godoxy/internal/logging/accesslog"
|
||||
expect "github.com/yusing/godoxy/internal/utils/testing"
|
||||
expect "github.com/yusing/goutils/testing"
|
||||
)
|
||||
|
||||
func TestParseRetention(t *testing.T) {
|
||||
|
||||
@@ -6,8 +6,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
"github.com/yusing/godoxy/internal/utils"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
strutils "github.com/yusing/goutils/strings"
|
||||
"github.com/yusing/goutils/synk"
|
||||
)
|
||||
@@ -251,14 +251,14 @@ func rotateLogFileBySize(file supportRotate, config *Retention) (result *RotateR
|
||||
// otherwise it returns zero time.
|
||||
func ParseLogTime(line []byte) (t time.Time) {
|
||||
if len(line) == 0 {
|
||||
return
|
||||
return t
|
||||
}
|
||||
|
||||
if timeStr := ExtractTime(line); timeStr != nil {
|
||||
t, _ = time.Parse(LogTimeFormat, string(timeStr)) // ignore error
|
||||
return
|
||||
return t
|
||||
}
|
||||
return
|
||||
return t
|
||||
}
|
||||
|
||||
var timeJSON = []byte(`"time":"`)
|
||||
@@ -272,8 +272,8 @@ func ExtractTime(line []byte) []byte {
|
||||
switch line[0] {
|
||||
case '{': // JSON format
|
||||
if i := bytes.Index(line, timeJSON); i != -1 {
|
||||
var jsonStart = i + len(`"time":"`)
|
||||
var jsonEnd = i + len(`"time":"`) + len(LogTimeFormat)
|
||||
jsonStart := i + len(`"time":"`)
|
||||
jsonEnd := i + len(`"time":"`) + len(LogTimeFormat)
|
||||
if len(line) < jsonEnd {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -7,10 +7,10 @@ import (
|
||||
"time"
|
||||
|
||||
. "github.com/yusing/godoxy/internal/logging/accesslog"
|
||||
"github.com/yusing/godoxy/internal/task"
|
||||
"github.com/yusing/godoxy/internal/utils"
|
||||
expect "github.com/yusing/godoxy/internal/utils/testing"
|
||||
expect "github.com/yusing/goutils/testing"
|
||||
strutils "github.com/yusing/goutils/strings"
|
||||
"github.com/yusing/goutils/task"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -3,7 +3,7 @@ package accesslog
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/yusing/godoxy/internal/gperr"
|
||||
gperr "github.com/yusing/goutils/errs"
|
||||
strutils "github.com/yusing/goutils/strings"
|
||||
)
|
||||
|
||||
|
||||
@@ -61,11 +61,11 @@ func (m *memLogger) Write(p []byte) (n int, err error) {
|
||||
pos, err := m.writeBuf(p)
|
||||
if err != nil {
|
||||
// not logging the error here, it will cause Run to be called again = infinite loop
|
||||
return
|
||||
return n, err
|
||||
}
|
||||
|
||||
m.notifyWS(pos, n)
|
||||
return
|
||||
return n, err
|
||||
}
|
||||
|
||||
func (m *memLogger) ServeHTTP(c *gin.Context) {
|
||||
@@ -149,7 +149,7 @@ func (m *memLogger) writeBuf(b []byte) (pos int, err error) {
|
||||
defer m.Unlock()
|
||||
pos = m.Len()
|
||||
_, err = m.Buffer.Write(b)
|
||||
return
|
||||
return pos, err
|
||||
}
|
||||
|
||||
func (m *memLogger) events() (logs <-chan []byte, cancel func()) {
|
||||
|
||||
Reference in New Issue
Block a user