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
2 changes: 1 addition & 1 deletion .chglog/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ style: github
template: CHANGELOG.tpl.md
info:
title: CHANGELOG
repository_url: https://github.com/DoNewsCode/core
repository_url: https://github.com/yanghp/core
options:
commits:
filters:
Expand Down
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
284 changes: 142 additions & 142 deletions CHANGELOG.md

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ English | [中文](./README_CN.md)
</p>
<p>

[![Build](https://github.com/DoNewsCode/core/actions/workflows/go.yml/badge.svg)](https://github.com/DoNewsCode/core/actions/workflows/go.yml)
[![Go Reference](https://pkg.go.dev/badge/github.com/DoNewsCode/core.svg)](https://pkg.go.dev/github.com/DoNewsCode/core)
[![codecov](https://codecov.io/gh/DoNewsCode/core/branch/master/graph/badge.svg)](https://codecov.io/gh/DoNewsCode/core)
[![Go Report Card](https://goreportcard.com/badge/DoNewsCode/core)](https://goreportcard.com/report/DoNewsCode/core)
[![Release](https://img.shields.io/github/release/DoNewsCode/core.svg)](https://github.com/DoNewsCode/core/releases/latest)
[![Build](https://github.com/yanghp/core/actions/workflows/go.yml/badge.svg)](https://github.com/yanghp/core/actions/workflows/go.yml)
[![Go Reference](https://pkg.go.dev/badge/github.com/yanghp/core.svg)](https://pkg.go.dev/github.com/yanghp/core)
[![codecov](https://codecov.io/gh/yanghp/core/branch/master/graph/badge.svg)](https://codecov.io/gh/yanghp/core)
[![Go Report Card](https://goreportcard.com/badge/yanghp/core)](https://goreportcard.com/report/yanghp/core)
[![Release](https://img.shields.io/github/release/yanghp/core.svg)](https://github.com/yanghp/core/releases/latest)
</p>
</div>

Expand Down Expand Up @@ -66,9 +66,9 @@ import (
"context"
"net/http"

"github.com/DoNewsCode/core"
"github.com/DoNewsCode/core/observability"
"github.com/DoNewsCode/core/otgorm"
"github.com/yanghp/core"
"github.com/yanghp/core/observability"
"github.com/yanghp/core/otgorm"
"github.com/gorilla/mux"
)

Expand Down Expand Up @@ -111,9 +111,9 @@ import (
"context"
"net/http"

"github.com/DoNewsCode/core"
"github.com/DoNewsCode/core/otgorm"
"github.com/DoNewsCode/core/srvhttp"
"github.com/yanghp/core"
"github.com/yanghp/core/otgorm"
"github.com/yanghp/core/srvhttp"
"github.com/gorilla/mux"
"gorm.io/gorm"
)
Expand Down Expand Up @@ -194,18 +194,18 @@ That being said, let's redirect our attention to other goodies package core has
You could start you project as a monolith with multiple modules, and gradually migrate them into microservices.

- Package core doesn't lock in transport or framework.
For instance, you can use go kit to construct your services, and bring in transports like gRPC, AMQP, thrift, etc. Non-network services like CLI and Cron are also supported. See [all available interfaces a module can expose](https://github.com/DoNewsCode/core/blob/master/container/container.go). You can also invent your own.
For instance, you can use go kit to construct your services, and bring in transports like gRPC, AMQP, thrift, etc. Non-network services like CLI and Cron are also supported. See [all available interfaces a module can expose](https://github.com/yanghp/core/blob/master/container/container.go). You can also invent your own.

- Package core also babysits the services after initialization. The duty includes but not limited to distributed tracing, metrics exporting, error handling, event-dispatching, and leader election.

Be sure to checkout the documentation section to learn more.

## Documentation

* [Tutorial](https://github.com/DoNewsCode/core/blob/master/doc/tutorial.md)
* [GoDoc](https://pkg.go.dev/github.com/DoNewsCode/core)
* [Starter Template](https://github.com/DoNewsCode/core-starter)
* [Contributing](https://github.com/DoNewsCode/core/blob/master/doc/contributing.md)
* [Tutorial](https://github.com/yanghp/core/blob/master/doc/tutorial.md)
* [GoDoc](https://pkg.go.dev/github.com/yanghp/core)
* [Starter Template](https://github.com/yanghp/core-starter)
* [Contributing](https://github.com/yanghp/core/blob/master/doc/contributing.md)

## Design Principles

Expand All @@ -223,8 +223,8 @@ Be sure to checkout the documentation section to learn more.
- Tries to reimplement the functionality provided by modern platforms.

## Works well with
- [Gin](https://github.com/DoNewsCode/core-gin) (if HTTP only)
- [Go Kit](https://github.com/DoNewsCode/core-kit) (if multiple transports)
- [Gin](https://github.com/yanghp/core-gin) (if HTTP only)
- [Go Kit](https://github.com/yanghp/core-kit) (if multiple transports)
- [Kratos v2](https://github.com/go-kratos/kratos)

## Thanks for JetBrains OS licenses
Expand Down
24 changes: 12 additions & 12 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ import (
"context"
"net/http"

"github.com/DoNewsCode/core"
"github.com/DoNewsCode/core/observability"
"github.com/DoNewsCode/core/otgorm"
"github.com/yanghp/core"
"github.com/yanghp/core/observability"
"github.com/yanghp/core/otgorm"
"github.com/gorilla/mux"
)

Expand Down Expand Up @@ -86,9 +86,9 @@ import (
"context"
"net/http"

"github.com/DoNewsCode/core"
"github.com/DoNewsCode/core/otgorm"
"github.com/DoNewsCode/core/srvhttp"
"github.com/yanghp/core"
"github.com/yanghp/core/otgorm"
"github.com/yanghp/core/srvhttp"
"github.com/gorilla/mux"
"gorm.io/gorm"
)
Expand Down Expand Up @@ -168,11 +168,11 @@ type HTTPProvider interface {

## 文档

- [教程](https://github.com/DoNewsCode/core/blob/master/doc/tutorial_cn.md)
- [GoDoc](https://pkg.go.dev/github.com/DoNewsCode/core)
- [教程](https://github.com/yanghp/core/blob/master/doc/tutorial_cn.md)
- [GoDoc](https://pkg.go.dev/github.com/yanghp/core)
- [Demo Project](https://github.com/DoNewsCode/skeleton)
- [初始模版](https://github.com/DoNewsCode/core-starter)
- [Contributing](https://github.com/DoNewsCode/core/blob/master/doc/contributing.markdown)
- [初始模版](https://github.com/yanghp/core-starter)
- [Contributing](https://github.com/yanghp/core/blob/master/doc/contributing.markdown)

## 设计原则

Expand All @@ -191,8 +191,8 @@ type HTTPProvider interface {

## 建议的服务框架

- [Gin](https://github.com/DoNewsCode/core-gin) (如果仅限于 HTTP)
- [Go Kit](https://github.com/DoNewsCode/core-kit) (如果有多个运输工具)
- [Gin](https://github.com/yanghp/core-gin) (如果仅限于 HTTP)
- [Go Kit](https://github.com/yanghp/core-kit) (如果有多个运输工具)
- [kratos](https://github.com/go-kratos/kratos) (当前 v2 已经可以使用)

## 感谢 JetBrains 开源证书支持
Expand Down
14 changes: 7 additions & 7 deletions c.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import (
"fmt"
"reflect"

"github.com/DoNewsCode/core/codec/yaml"
"github.com/DoNewsCode/core/config"
"github.com/DoNewsCode/core/config/watcher"
"github.com/DoNewsCode/core/container"
"github.com/DoNewsCode/core/contract"
"github.com/DoNewsCode/core/di"
"github.com/DoNewsCode/core/logging"
"github.com/yanghp/core/codec/yaml"
"github.com/yanghp/core/config"
"github.com/yanghp/core/config/watcher"
"github.com/yanghp/core/container"
"github.com/yanghp/core/contract"
"github.com/yanghp/core/di"
"github.com/yanghp/core/logging"

"github.com/go-kit/log"
"github.com/knadh/koanf/providers/confmap"
Expand Down
28 changes: 18 additions & 10 deletions c_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,31 @@ package core
import (
"context"
"io/ioutil"
"net"
"os"
"strings"
"sync/atomic"
"testing"
"time"

"github.com/DoNewsCode/core/config"
"github.com/DoNewsCode/core/contract/lifecycle"
"github.com/DoNewsCode/core/di"
"github.com/DoNewsCode/core/otgorm"
"github.com/DoNewsCode/core/srvgrpc"
"github.com/DoNewsCode/core/srvhttp"
"github.com/yanghp/core/config"
"github.com/yanghp/core/contract/lifecycle"
"github.com/yanghp/core/di"
"github.com/yanghp/core/otgorm"
"github.com/yanghp/core/srvgrpc"
"github.com/yanghp/core/srvhttp"

"github.com/spf13/cobra"
"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
2 changes: 1 addition & 1 deletion clihttp/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"io/ioutil"
"net/http"

"github.com/DoNewsCode/core/contract"
"github.com/yanghp/core/contract"

"github.com/opentracing-contrib/go-stdlib/nethttp"
"github.com/opentracing/opentracing-go"
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
4 changes: 2 additions & 2 deletions clihttp/dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package clihttp
import (
"fmt"

"github.com/DoNewsCode/core/contract"
"github.com/DoNewsCode/core/di"
"github.com/yanghp/core/contract"
"github.com/yanghp/core/di"

"github.com/opentracing/opentracing-go"
)
Expand Down
2 changes: 1 addition & 1 deletion clihttp/dependency_option.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package clihttp

import "github.com/DoNewsCode/core/contract"
import "github.com/yanghp/core/contract"

type providersOption struct {
clientConstructor func(args ClientArgs) (contract.HttpDoer, error)
Expand Down
8 changes: 4 additions & 4 deletions clihttp/dependency_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import (
"net/http"
"testing"

"github.com/DoNewsCode/core"
"github.com/DoNewsCode/core/clihttp"
"github.com/DoNewsCode/core/contract"
"github.com/DoNewsCode/core/observability"
"github.com/yanghp/core"
"github.com/yanghp/core/clihttp"
"github.com/yanghp/core/contract"
"github.com/yanghp/core/observability"

"github.com/stretchr/testify/assert"
)
Expand Down
2 changes: 1 addition & 1 deletion config/app_name.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package config

import "github.com/DoNewsCode/core/contract"
import "github.com/yanghp/core/contract"

// AppName represents the name the application. It is primarily used as a symbol for dependency injection.
type AppName string
Expand Down
2 changes: 1 addition & 1 deletion config/codec_parser.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package config

import (
"github.com/DoNewsCode/core/contract"
"github.com/yanghp/core/contract"
)

// CodecParser implements the Parser interface. It converts any contract.Codec to
Expand Down
2 changes: 1 addition & 1 deletion config/codec_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"io/ioutil"
"testing"

"github.com/DoNewsCode/core/codec/yaml"
"github.com/yanghp/core/codec/yaml"

yaml2 "github.com/knadh/koanf/parsers/yaml"
"github.com/stretchr/testify/assert"
Expand Down
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"sync"
"time"

"github.com/DoNewsCode/core/contract"
"github.com/DoNewsCode/core/contract/lifecycle"
"github.com/yanghp/core/contract"
"github.com/yanghp/core/contract/lifecycle"

"github.com/knadh/koanf"
"github.com/knadh/koanf/providers/confmap"
Expand Down
2 changes: 1 addition & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"testing"
"time"

"github.com/DoNewsCode/core/config/watcher"
"github.com/yanghp/core/config/watcher"

"github.com/knadh/koanf"
"github.com/knadh/koanf/parsers/json"
Expand Down
2 changes: 1 addition & 1 deletion config/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package config
import (
"strings"

"github.com/DoNewsCode/core/contract"
"github.com/yanghp/core/contract"
)

// global static variables for Env
Expand Down
2 changes: 1 addition & 1 deletion config/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"flag"
"fmt"

"github.com/DoNewsCode/core/config"
"github.com/yanghp/core/config"

"github.com/knadh/koanf/parsers/json"
"github.com/knadh/koanf/providers/basicflag"
Expand Down
Loading