Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
build:
strategy:
matrix:
go-version: [ 1.18.x ]
go-version: [ 1.25.x ]
runs-on: ubuntu-latest
services:
redis:
Expand All @@ -22,7 +22,7 @@ jobs:
ports:
- 6379:6379
etcd:
image: gcr.io/etcd-development/etcd:v3.5.0
image: gcr.io/etcd-development/etcd:v3.6.14
ports:
- 2379:2379
env:
Expand Down Expand Up @@ -104,7 +104,7 @@ jobs:
lint:
strategy:
matrix:
go-version: [ 1.18.x ]
go-version: [ 1.25.x ]
name: lint
runs-on: ubuntu-latest
steps:
Expand All @@ -115,6 +115,6 @@ jobs:
- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.45.2
version: v2.8.0
args: --disable errcheck --timeout 5m0s
only-new-issues: true
16 changes: 12 additions & 4 deletions c_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package core
import (
"context"
"io/ioutil"
"net"
"os"
"strings"
"sync/atomic"
Expand All @@ -20,6 +21,13 @@ import (
"github.com/stretchr/testify/assert"
)

func assertListenerPort(t *testing.T, addr, port string) {
t.Helper()
_, gotPort, err := net.SplitHostPort(addr)
assert.NoError(t, err)
assert.Equal(t, port, gotPort)
}

func TestC_Serve(t *testing.T) {
var called int32
c := New(
Expand All @@ -33,28 +41,28 @@ func TestC_Serve(t *testing.T) {
c.Invoke(func(dispatcher lifecycle.HTTPServerStart) {
dispatcher.On(func(ctx context.Context, start lifecycle.HTTPServerStartPayload) error {
atomic.AddInt32(&called, 1)
assert.Equal(t, "[::]:19998", start.Listener.Addr().String())
assertListenerPort(t, start.Listener.Addr().String(), "19998")
return nil
})
})
c.Invoke(func(dispatcher lifecycle.HTTPServerShutdown) {
dispatcher.On(func(ctx context.Context, shutdown lifecycle.HTTPServerShutdownPayload) error {
atomic.AddInt32(&called, 1)
assert.Equal(t, "[::]:19998", shutdown.Listener.Addr().String())
assertListenerPort(t, shutdown.Listener.Addr().String(), "19998")
return nil
})
})
c.Invoke(func(dispatcher lifecycle.GRPCServerStart) {
dispatcher.On(func(ctx context.Context, start lifecycle.GRPCServerStartPayload) error {
atomic.AddInt32(&called, 1)
assert.Equal(t, "[::]:19999", start.Listener.Addr().String())
assertListenerPort(t, start.Listener.Addr().String(), "19999")
return nil
})
})
c.Invoke(func(dispatcher lifecycle.GRPCServerShutdown) {
dispatcher.On(func(ctx context.Context, shutdown lifecycle.GRPCServerShutdownPayload) error {
atomic.AddInt32(&called, 1)
assert.Equal(t, "[::]:19999", shutdown.Listener.Addr().String())
assertListenerPort(t, shutdown.Listener.Addr().String(), "19999")
return nil
})
})
Expand Down
7 changes: 5 additions & 2 deletions clihttp/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ func TestClient_race(t *testing.T) {
t.Run("", func(t *testing.T) {
t.Parallel()
r, _ := http.NewRequest("GET", "https://example.com/", nil)
resp, _ := client.Do(r)
defer resp.Body.Close()
resp, err := client.Do(r)
if resp != nil {
defer resp.Body.Close()
}
_ = err
})
}
}
Expand Down
3 changes: 3 additions & 0 deletions config/testdata/module_test_partial.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"foo": "bar"
}
2 changes: 2 additions & 0 deletions config/testdata/module_test_partial.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# A mock config
foo: bar
166 changes: 81 additions & 85 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,111 +1,107 @@
module github.com/DoNewsCode/core

go 1.18
go 1.25.0

require (
github.com/aws/aws-sdk-go v1.40.45
github.com/felixge/httpsnoop v1.0.1
github.com/fsnotify/fsnotify v1.4.9
github.com/gabriel-vasile/mimetype v1.1.2
github.com/go-gormigrate/gormigrate/v2 v2.0.0
github.com/go-kit/kit v0.12.0
github.com/go-kit/log v0.2.0
github.com/go-redis/redis/v8 v8.11.4
github.com/golang/mock v1.5.0
github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0
github.com/aws/aws-sdk-go v1.55.8
github.com/felixge/httpsnoop v1.1.0
github.com/fsnotify/fsnotify v1.10.1
github.com/gabriel-vasile/mimetype v1.4.15
github.com/go-gormigrate/gormigrate/v2 v2.1.6
github.com/go-kit/kit v0.13.0
github.com/go-kit/log v0.2.1
github.com/go-redis/redis/v8 v8.11.5
github.com/golang/mock v1.6.0
github.com/gorilla/handlers v1.5.2
github.com/gorilla/mux v1.8.1
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/heptiolabs/healthcheck v0.0.0-20180807145615-6ff867650f40
github.com/knadh/koanf v1.4.0
github.com/mitchellh/mapstructure v1.4.2
github.com/oklog/run v1.1.0
github.com/olivere/elastic/v7 v7.0.22
github.com/opentracing-contrib/go-grpc v0.0.0-20210225150812-73cb765af46e
github.com/opentracing-contrib/go-stdlib v1.0.0
github.com/hashicorp/go-version v1.9.0 // indirect
github.com/heptiolabs/healthcheck v0.0.0-20211123025425-613501dd5deb
github.com/knadh/koanf v1.5.0
github.com/mitchellh/mapstructure v1.5.0
github.com/oklog/run v1.2.0
github.com/olivere/elastic/v7 v7.0.32
github.com/opentracing-contrib/go-grpc v0.1.4
github.com/opentracing-contrib/go-stdlib v1.1.1
github.com/opentracing/opentracing-go v1.2.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.11.0
github.com/prometheus/client_golang v1.24.1
github.com/robfig/cron/v3 v3.0.1
github.com/segmentio/kafka-go v0.4.16
github.com/spf13/cobra v1.1.3
github.com/stretchr/testify v1.8.2
github.com/uber/jaeger-client-go v2.25.0+incompatible
github.com/uber/jaeger-lib v2.4.0+incompatible
go.etcd.io/etcd/client/v3 v3.5.0
go.mongodb.org/mongo-driver v1.11.1
go.uber.org/atomic v1.10.0
go.uber.org/dig v1.14.1
go.uber.org/zap v1.24.0
golang.org/x/sync v0.0.0-20220923202941-7f9b1623fab7
google.golang.org/grpc v1.47.0
google.golang.org/protobuf v1.28.0
github.com/segmentio/kafka-go v0.4.51
github.com/spf13/cobra v1.10.2
github.com/stretchr/testify v1.11.1
github.com/uber/jaeger-client-go v2.30.0+incompatible
github.com/uber/jaeger-lib v2.4.1+incompatible
go.etcd.io/etcd/client/v3 v3.6.14
go.mongodb.org/mongo-driver v1.17.9
go.uber.org/atomic v1.11.0
go.uber.org/dig v1.19.0
go.uber.org/zap v1.28.0
golang.org/x/sync v0.22.0
google.golang.org/grpc v1.83.0
google.golang.org/protobuf v1.36.11
gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0 // indirect
gopkg.in/yaml.v3 v3.0.1
gorm.io/driver/clickhouse v0.5.0
gorm.io/driver/mysql v1.4.7
gorm.io/driver/postgres v1.1.0 // indirect
gorm.io/driver/sqlite v1.4.4
gorm.io/driver/sqlserver v1.0.7 // indirect
gorm.io/gorm v1.24.6
gorm.io/driver/clickhouse v0.7.0
gorm.io/driver/mysql v1.6.0
gorm.io/driver/sqlite v1.6.0
gorm.io/gorm v1.31.2
)

require (
github.com/ClickHouse/ch-go v0.53.0 // indirect
github.com/ClickHouse/clickhouse-go/v2 v2.6.5 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
filippo.io/edwards25519 v1.2.0 // indirect
github.com/ClickHouse/ch-go v0.74.0 // indirect
github.com/ClickHouse/clickhouse-go/v2 v2.48.0 // indirect
github.com/andybalholm/brotli v1.2.2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/go-faster/city v1.0.1 // indirect
github.com/go-faster/errors v0.6.1 // indirect
github.com/go-logfmt/logfmt v0.5.1 // indirect
github.com/go-sql-driver/mysql v1.7.0 // indirect
github.com/go-faster/errors v0.8.0 // indirect
github.com/go-logfmt/logfmt v0.6.1 // indirect
github.com/go-sql-driver/mysql v1.10.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.16.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattn/go-sqlite3 v1.14.16 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/klauspost/compress v1.19.2 // indirect
github.com/mailru/easyjson v0.9.2 // indirect
github.com/mattn/go-sqlite3 v1.14.49 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/paulmach/orb v0.9.0 // indirect
github.com/pierrec/lz4 v2.6.0+incompatible // indirect
github.com/pierrec/lz4/v4 v4.1.17 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.30.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/segmentio/asm v1.2.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/montanaflynn/stats v0.7.1 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/paulmach/orb v0.13.0 // indirect
github.com/pierrec/lz4/v4 v4.1.28 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.70.1 // indirect
github.com/prometheus/procfs v0.21.1 // indirect
github.com/segmentio/asm v1.2.1 // indirect
github.com/shopspring/decimal v1.4.0 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.1 // indirect
github.com/xdg-go/stringprep v1.0.3 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
go.etcd.io/etcd/api/v3 v3.5.0 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.0 // indirect
go.opentelemetry.io/otel v1.14.0 // indirect
go.opentelemetry.io/otel/trace v1.14.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d // indirect
golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect
go.etcd.io/etcd/api/v3 v3.6.14 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.6.14 // indirect
go.opentelemetry.io/otel v1.45.0 // indirect
go.opentelemetry.io/otel/trace v1.45.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.54.0 // indirect
golang.org/x/net v0.57.0 // indirect
golang.org/x/sys v0.47.0 // indirect
golang.org/x/text v0.40.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260803160001-6ac0973c030d // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260803160001-6ac0973c030d // indirect
)
Loading