DaWesen opened a new pull request, #3695:
URL: https://github.com/apache/dubbo-go/pull/3695

   ### Description
   Fixes #3691
   
   Migrate dubbo-go production code off the gost standard-library thin wrappers,
   `go.uber.org/atomic` and `github.com/pkg/errors`, replacing them with 
standard
   library implementations. This PR only migrates production call sites; the 
gost
   public packages are kept intact to leave a compatibility window for external
   users.
   
   #### 1. Replacement scope
   
   | Dependency | Replaced with | Where |
   | --- | --- | --- |
   | gost/time | time.After | getty heartbeat timeout wait (listener.go) |
   | gost/sort | slices.Sort | call sites rewritten; Prioritizer has no 
production callers, not migrated |
   | gost/hash/page (Pager) | local registry.Pager | moved to registry/page.go |
   | gost/strings | strings / regexp / reflect | call sites rewritten |
   | gost/net | net + local helper | common/host_util.go |
   | gost/path/filepath | os.Stat / io/fs | call sites rewritten |
   | gost/runtime.GoSafely | local goSafely helper | loader.go |
   | go.uber.org/atomic | sync/atomic typed atomics | replaced globally; go.mod 
downgraded to // indirect |
   | github.com/pkg/errors | errors / fmt.Errorf("%w") | all 
New/Errorf/Wrap/Wrapf/WithMessage replaced |
   
   #### 2. Error handling: error chains and stack traces (needs a dedicated 
review)
   
   **Error chains (errors.Is/As semantics unchanged)**
   - `perrors.New/Errorf/Wrap/Wrapf/WithMessage` are replaced with `errors.New` 
/
     `fmt.Errorf("%w")`; the chain is preserved layer by layer via `%w`, so
     `errors.Is` / `errors.As` still match any layer of the chain.
   - `perrors.Cause` has no direct stdlib equivalent; a `resolveRootCause` 
helper is
     added in the `proxy` package that walks both `Unwrap()` and `Cause()` 
chains,
     preserving the original `perrors.Cause` behavior (covered by a regression 
test).
   
   **Stack traces (kept, not blindly removed)**
   - The remaining `pkg/errors` usages in the main module are all
     `perrors.WithStack` (~160 sites across ~31 production files, mostly at 
error
     return boundaries and log emission points). The stdlib has no equivalent 
for
     capturing a call stack; replacing them would lose the stack needed for
     debugging, so they are intentionally kept.
   - Cost: `github.com/pkg/errors` therefore remains a direct dependency; usage 
is
     reduced but cannot yet be zeroed. Removing it entirely requires adopting a
     stdlib-based stack solution first (e.g. manual capture via
     `runtime/debug.Stack()`), which is tracked as a follow-up issue.
   
   #### 3. Compatibility window: gost public packages are not deleted
   - The external module `github.com/dubbogo/gost` is kept (v1.14.5); no public
     packages are removed in this PR, so external users are not broken at once.
   - Deprecation notes for the thin wrappers will be added in the gost 
repository
     (it cannot be modified from this repo; tracked as a follow-up).
   
   #### 4. Domain interface migration
   - `Pager` (previously `gost/hash/page`): moved to the `registry` package
     (`registry/page.go`); the etcdv3/nacos/zookeeper/polaris service 
discoveries
     now use the local implementation.
   - `Prioritizer` (from `gost/sort`): a repository-wide search confirmed there 
are
     no production call sites, so no migration is needed.
   
   #### 5. Explicitly out of scope
   `container/set`, unbounded channels, `TaskPool`, observer and logger have no
   direct stdlib equivalent and are not modified; `gost/log/logger`,
   `container/set` and `database/kv` remain in use by production code.
   
   #### 6. Independent module note
   `tools/dubbogo-cli` is a separate Go module (its own go.mod and CI) that 
still
   uses `pkg/errors` and `go.uber.org/atomic`; it is not part of this PR.
   
   #### 7. Regression tests
   - pagination / sort: `registry/page_test.go`
   - error chain: `proxy.TestResolveRootCause`
   - recover: `loader.TestGoSafely_RunsAndRecoversPanic`
   - timeout (request read timeout): 
`remoting/getty.TestRequestContextReadTimeout`
   - timeout (gost/time migration, heartbeat): 
`remoting/getty.TestHeartbeatTimeoutCleanup`
   
   Also fixes the `staticcheck` ST1005/ST1012 and `testifylint` findings 
exposed by
   the migration.
   
   #### 8. Retained compatibility layers and deletion plan
   - `pkg/errors.WithStack`: no stdlib equivalent; to be replaced once a
     stdlib-based stack solution is adopted.
   - `github.com/dubbogo/gost`: still used for container/set, log/logger and
     database/kv (out of scope); deprecation of the thin wrappers will be added 
in
     the gost repository.
   - `tools/dubbogo-cli`: independent module, tracked separately.
   
   ### Checklist
   - [x] I confirm the target branch is `develop`
   - [x] I have run `make fmt` to format my code
   - [x] I have run `make test` to run local tests
   - [x] I have added tests that prove my fix is effective or that my feature 
works
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to