Showing preview only (2,130K chars total). Download the full file or copy to clipboard to get everything.
Repository: go-kratos/kratos
Branch: main
Commit: e36259de52a8
Files: 461
Total size: 2.0 MB
Directory structure:
gitextract_rshunaq6/
├── .github/
│ ├── FUNDING.yml
│ ├── ISSUE_TEMPLATE/
│ │ ├── bug-report.md
│ │ ├── config.yml
│ │ ├── feature-request.md
│ │ ├── proposal.md
│ │ └── question.md
│ ├── dependabot.yml
│ ├── pull_request_template.md
│ ├── semantic.yml
│ ├── stable.yml
│ └── workflows/
│ ├── codeql-analysis.yml
│ ├── comment-check.yml
│ ├── gitee-sync.yml
│ ├── go.yml
│ ├── issue-translator.yml
│ └── lint.yml
├── .gitignore
├── .golangci.yml
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── Makefile
├── README.md
├── README_zh.md
├── ROADMAP.md
├── SECURITY.md
├── api/
│ ├── README.md
│ └── metadata/
│ ├── metadata.pb.go
│ ├── metadata.proto
│ ├── metadata_grpc.pb.go
│ ├── metadata_http.pb.go
│ └── server.go
├── app.go
├── app_test.go
├── cmd/
│ ├── kratos/
│ │ ├── go.mod
│ │ ├── go.sum
│ │ ├── internal/
│ │ │ ├── base/
│ │ │ │ ├── install.go
│ │ │ │ ├── mod.go
│ │ │ │ ├── mod_test.go
│ │ │ │ ├── path.go
│ │ │ │ ├── repo.go
│ │ │ │ ├── repo_test.go
│ │ │ │ ├── vcs_url.go
│ │ │ │ └── vcs_url_test.go
│ │ │ ├── change/
│ │ │ │ ├── change.go
│ │ │ │ ├── get.go
│ │ │ │ └── get_test.go
│ │ │ ├── project/
│ │ │ │ ├── add.go
│ │ │ │ ├── new.go
│ │ │ │ ├── project.go
│ │ │ │ ├── project_linux_test.go
│ │ │ │ ├── project_test.go
│ │ │ │ └── project_windows_test.go
│ │ │ ├── proto/
│ │ │ │ ├── add/
│ │ │ │ │ ├── add.go
│ │ │ │ │ ├── add_test.go
│ │ │ │ │ ├── proto.go
│ │ │ │ │ └── template.go
│ │ │ │ ├── client/
│ │ │ │ │ └── client.go
│ │ │ │ ├── proto.go
│ │ │ │ └── server/
│ │ │ │ ├── server.go
│ │ │ │ ├── server_test.go
│ │ │ │ └── template.go
│ │ │ ├── run/
│ │ │ │ └── run.go
│ │ │ └── upgrade/
│ │ │ └── upgrade.go
│ │ ├── main.go
│ │ └── version.go
│ ├── protoc-gen-go-errors/
│ │ ├── buf.gen.yaml
│ │ ├── buf.yaml
│ │ ├── errors/
│ │ │ ├── errors.pb.go
│ │ │ └── errors.proto
│ │ ├── errors.go
│ │ ├── errorsTemplate.tpl
│ │ ├── errors_test.go
│ │ ├── go.mod
│ │ ├── go.sum
│ │ ├── main.go
│ │ ├── template.go
│ │ └── version.go
│ └── protoc-gen-go-http/
│ ├── go.mod
│ ├── go.sum
│ ├── http.go
│ ├── httpTemplate.tpl
│ ├── http_test.go
│ ├── main.go
│ ├── template.go
│ └── version.go
├── codecov.yml
├── config/
│ ├── README.md
│ ├── config.go
│ ├── config_test.go
│ ├── env/
│ │ ├── env.go
│ │ ├── env_test.go
│ │ ├── watcher.go
│ │ └── watcher_test.go
│ ├── file/
│ │ ├── file.go
│ │ ├── file_test.go
│ │ ├── format.go
│ │ ├── format_test.go
│ │ └── watcher.go
│ ├── options.go
│ ├── options_test.go
│ ├── reader.go
│ ├── reader_test.go
│ ├── source.go
│ ├── value.go
│ └── value_test.go
├── contrib/
│ ├── config/
│ │ ├── apollo/
│ │ │ ├── README.md
│ │ │ ├── apollo.go
│ │ │ ├── apollo_test.go
│ │ │ ├── go.mod
│ │ │ ├── go.sum
│ │ │ ├── parser.go
│ │ │ ├── watcher.go
│ │ │ └── watcher_test.go
│ │ ├── consul/
│ │ │ ├── README.md
│ │ │ ├── config.go
│ │ │ ├── config_test.go
│ │ │ ├── go.mod
│ │ │ ├── go.sum
│ │ │ └── watcher.go
│ │ ├── etcd/
│ │ │ ├── README.md
│ │ │ ├── config.go
│ │ │ ├── config_test.go
│ │ │ ├── go.mod
│ │ │ ├── go.sum
│ │ │ └── watcher.go
│ │ ├── kubernetes/
│ │ │ ├── README.md
│ │ │ ├── config.go
│ │ │ ├── config_test.go
│ │ │ ├── go.mod
│ │ │ ├── go.sum
│ │ │ ├── watcher.go
│ │ │ └── watcher_test.go
│ │ ├── nacos/
│ │ │ ├── README.md
│ │ │ ├── config.go
│ │ │ ├── config_test.go
│ │ │ ├── go.mod
│ │ │ ├── go.sum
│ │ │ └── watcher.go
│ │ └── polaris/
│ │ ├── README.md
│ │ ├── config.go
│ │ ├── go.mod
│ │ ├── go.sum
│ │ ├── polaris.yaml
│ │ └── watcher.go
│ ├── encoding/
│ │ └── msgpack/
│ │ ├── go.mod
│ │ ├── go.sum
│ │ ├── msgpack.go
│ │ └── msgpack_test.go
│ ├── errortracker/
│ │ └── sentry/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ ├── sentry.go
│ │ └── sentry_test.go
│ ├── log/
│ │ ├── aliyun/
│ │ │ ├── aliyun.go
│ │ │ ├── aliyun_test.go
│ │ │ ├── go.mod
│ │ │ └── go.sum
│ │ ├── fluent/
│ │ │ ├── fluent.go
│ │ │ ├── fluent_test.go
│ │ │ ├── go.mod
│ │ │ └── go.sum
│ │ ├── logrus/
│ │ │ ├── go.mod
│ │ │ ├── go.sum
│ │ │ ├── logrus.go
│ │ │ └── logrus_test.go
│ │ ├── tencent/
│ │ │ ├── go.mod
│ │ │ ├── go.sum
│ │ │ ├── tencent.go
│ │ │ └── tencent_test.go
│ │ ├── zap/
│ │ │ ├── go.mod
│ │ │ ├── go.sum
│ │ │ ├── zap.go
│ │ │ └── zap_test.go
│ │ └── zerolog/
│ │ ├── go.mod
│ │ ├── go.sum
│ │ ├── zerolog.go
│ │ └── zerolog_test.go
│ ├── middleware/
│ │ └── validate/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ ├── internal/
│ │ │ └── testdata/
│ │ │ ├── generate.go
│ │ │ ├── test.pb.go
│ │ │ ├── test.pb.validate.go
│ │ │ └── test.proto
│ │ ├── validate.go
│ │ └── validate_test.go
│ ├── opensergo/
│ │ ├── README.md
│ │ ├── go.mod
│ │ ├── go.sum
│ │ ├── opensergo.go
│ │ └── opensergo_test.go
│ ├── polaris/
│ │ ├── config.go
│ │ ├── config_test.go
│ │ ├── go.mod
│ │ ├── go.sum
│ │ ├── limiter.go
│ │ ├── polaris.go
│ │ ├── ratelimit.go
│ │ ├── registry.go
│ │ ├── registry_test.go
│ │ ├── router.go
│ │ └── router_test.go
│ ├── registry/
│ │ ├── consul/
│ │ │ ├── client.go
│ │ │ ├── go.mod
│ │ │ ├── go.sum
│ │ │ ├── registry.go
│ │ │ ├── registry_test.go
│ │ │ ├── service.go
│ │ │ └── watcher.go
│ │ ├── discovery/
│ │ │ ├── README.md
│ │ │ ├── discovery.go
│ │ │ ├── discovery_helper.go
│ │ │ ├── go.mod
│ │ │ ├── go.sum
│ │ │ ├── impl_discover.go
│ │ │ └── impl_registrar.go
│ │ ├── etcd/
│ │ │ ├── go.mod
│ │ │ ├── go.sum
│ │ │ ├── registry.go
│ │ │ ├── registry_test.go
│ │ │ ├── service.go
│ │ │ └── watcher.go
│ │ ├── eureka/
│ │ │ ├── client.go
│ │ │ ├── eureka.go
│ │ │ ├── go.mod
│ │ │ ├── go.sum
│ │ │ ├── register.go
│ │ │ ├── register_test.go
│ │ │ └── watcher.go
│ │ ├── kubernetes/
│ │ │ ├── go.mod
│ │ │ ├── go.sum
│ │ │ ├── registry.go
│ │ │ └── registry_test.go
│ │ ├── nacos/
│ │ │ ├── README.md
│ │ │ ├── go.mod
│ │ │ ├── go.sum
│ │ │ ├── registry.go
│ │ │ ├── registry_test.go
│ │ │ └── watcher.go
│ │ ├── polaris/
│ │ │ ├── go.mod
│ │ │ ├── go.sum
│ │ │ └── registry.go
│ │ ├── servicecomb/
│ │ │ ├── README.md
│ │ │ ├── go.mod
│ │ │ ├── go.sum
│ │ │ ├── registry.go
│ │ │ ├── registry_test.go
│ │ │ └── watcher.go
│ │ └── zookeeper/
│ │ ├── go.mod
│ │ ├── go.sum
│ │ ├── register.go
│ │ ├── register_test.go
│ │ ├── service.go
│ │ └── watcher.go
│ └── transport/
│ └── mcp/
│ ├── README.md
│ ├── go.mod
│ ├── go.sum
│ ├── server.go
│ └── server_test.go
├── docs/
│ ├── README.md
│ └── design/
│ └── kratos-v2.md
├── encoding/
│ ├── README.md
│ ├── encoding.go
│ ├── encoding_test.go
│ ├── form/
│ │ ├── form.go
│ │ ├── form_test.go
│ │ ├── proto_decode.go
│ │ ├── proto_decode_test.go
│ │ ├── proto_encode.go
│ │ ├── proto_encode_test.go
│ │ ├── well_known_types.go
│ │ └── well_known_types_test.go
│ ├── json/
│ │ ├── json.go
│ │ └── json_test.go
│ ├── proto/
│ │ ├── proto.go
│ │ └── proto_test.go
│ ├── xml/
│ │ ├── xml.go
│ │ └── xml_test.go
│ └── yaml/
│ ├── yaml.go
│ └── yaml_test.go
├── errors/
│ ├── errors.go
│ ├── errors.pb.go
│ ├── errors.proto
│ ├── errors_test.go
│ ├── types.go
│ ├── types_test.go
│ ├── wrap.go
│ └── wrap_test.go
├── go.mod
├── go.sum
├── hack/
│ ├── .lintcheck_failures
│ ├── .test_ignored_files
│ ├── resolve-modules.sh
│ ├── tools.sh
│ └── util.sh
├── internal/
│ ├── README.md
│ ├── context/
│ │ ├── context.go
│ │ └── context_test.go
│ ├── endpoint/
│ │ ├── endpoint.go
│ │ └── endpoint_test.go
│ ├── group/
│ │ ├── example_test.go
│ │ ├── group.go
│ │ └── group_test.go
│ ├── host/
│ │ ├── host.go
│ │ └── host_test.go
│ ├── httputil/
│ │ ├── http.go
│ │ └── http_test.go
│ ├── matcher/
│ │ ├── middleware.go
│ │ └── middleware_test.go
│ └── testdata/
│ ├── binding/
│ │ ├── generate.go
│ │ ├── test.pb.go
│ │ └── test.proto
│ ├── complex/
│ │ ├── complex.pb.go
│ │ ├── complex.proto
│ │ └── generate.go
│ ├── encoding/
│ │ ├── test.pb.go
│ │ └── test.proto
│ └── helloworld/
│ ├── generate.go
│ ├── helloworld.pb.go
│ ├── helloworld.proto
│ ├── helloworld_grpc.pb.go
│ └── helloworld_http.pb.go
├── log/
│ ├── README.md
│ ├── filter.go
│ ├── filter_test.go
│ ├── global.go
│ ├── global_test.go
│ ├── helper.go
│ ├── helper_test.go
│ ├── helper_writer.go
│ ├── helper_writer_test.go
│ ├── level.go
│ ├── level_test.go
│ ├── log.go
│ ├── log_test.go
│ ├── std.go
│ ├── std_test.go
│ ├── value.go
│ └── value_test.go
├── metadata/
│ ├── metadata.go
│ └── metadata_test.go
├── middleware/
│ ├── auth/
│ │ └── jwt/
│ │ ├── jwt.go
│ │ └── jwt_test.go
│ ├── circuitbreaker/
│ │ ├── circuitbreaker.go
│ │ └── circuitbreaker_test.go
│ ├── logging/
│ │ ├── logging.go
│ │ └── logging_test.go
│ ├── metadata/
│ │ ├── metadata.go
│ │ └── metadata_test.go
│ ├── metrics/
│ │ ├── metrics.go
│ │ ├── metrics_test.go
│ │ └── otel.go
│ ├── middleware.go
│ ├── middleware_test.go
│ ├── ratelimit/
│ │ ├── ratelimit.go
│ │ └── ratelimit_test.go
│ ├── recovery/
│ │ ├── recovery.go
│ │ └── recovery_test.go
│ ├── selector/
│ │ ├── selector.go
│ │ └── selector_test.go
│ ├── tracing/
│ │ ├── metadata.go
│ │ ├── metadata_test.go
│ │ ├── span.go
│ │ ├── span_test.go
│ │ ├── statshandler.go
│ │ ├── statshandler_test.go
│ │ ├── tracer.go
│ │ ├── tracer_test.go
│ │ ├── tracing.go
│ │ └── tracing_test.go
│ └── validate/
│ ├── validate.go
│ └── validate_test.go
├── options.go
├── options_test.go
├── registry/
│ ├── README.md
│ └── registry.go
├── selector/
│ ├── balancer.go
│ ├── default_node.go
│ ├── default_selector.go
│ ├── filter/
│ │ ├── version.go
│ │ └── version_test.go
│ ├── filter.go
│ ├── global.go
│ ├── node/
│ │ ├── direct/
│ │ │ ├── direct.go
│ │ │ └── direct_test.go
│ │ └── ewma/
│ │ ├── node.go
│ │ └── node_test.go
│ ├── options.go
│ ├── p2c/
│ │ ├── p2c.go
│ │ └── p2c_test.go
│ ├── peer.go
│ ├── peer_test.go
│ ├── random/
│ │ ├── random.go
│ │ └── random_test.go
│ ├── selector.go
│ ├── selector_test.go
│ └── wrr/
│ ├── wrr.go
│ └── wrr_test.go
├── third_party/
│ ├── README.md
│ ├── buf/
│ │ └── validate/
│ │ ├── README.md
│ │ └── validate.proto
│ ├── buf.yaml
│ ├── errors/
│ │ └── errors.proto
│ ├── google/
│ │ ├── api/
│ │ │ ├── annotations.proto
│ │ │ ├── client.proto
│ │ │ ├── field_behavior.proto
│ │ │ ├── http.proto
│ │ │ └── httpbody.proto
│ │ └── protobuf/
│ │ └── descriptor.proto
│ └── validate/
│ ├── README.md
│ └── validate.proto
├── transport/
│ ├── grpc/
│ │ ├── balancer.go
│ │ ├── balancer_test.go
│ │ ├── client.go
│ │ ├── client_test.go
│ │ ├── codec.go
│ │ ├── codec_test.go
│ │ ├── interceptor.go
│ │ ├── resolver/
│ │ │ ├── direct/
│ │ │ │ ├── builder.go
│ │ │ │ ├── builder_test.go
│ │ │ │ ├── resolver.go
│ │ │ │ └── resolver_test.go
│ │ │ └── discovery/
│ │ │ ├── builder.go
│ │ │ ├── builder_test.go
│ │ │ ├── resolver.go
│ │ │ └── resolver_test.go
│ │ ├── server.go
│ │ ├── server_test.go
│ │ ├── transport.go
│ │ └── transport_test.go
│ ├── http/
│ │ ├── binding/
│ │ │ ├── bind.go
│ │ │ ├── bind_test.go
│ │ │ ├── encode.go
│ │ │ └── encode_test.go
│ │ ├── calloption.go
│ │ ├── calloption_test.go
│ │ ├── client.go
│ │ ├── client_test.go
│ │ ├── codec.go
│ │ ├── codec_go1.20.go
│ │ ├── codec_test.go
│ │ ├── context.go
│ │ ├── context_test.go
│ │ ├── filter.go
│ │ ├── pprof/
│ │ │ └── pprof.go
│ │ ├── redirect.go
│ │ ├── redirect_test.go
│ │ ├── resolver.go
│ │ ├── resolver_test.go
│ │ ├── router.go
│ │ ├── router_test.go
│ │ ├── server.go
│ │ ├── server_test.go
│ │ ├── status/
│ │ │ ├── status.go
│ │ │ └── status_test.go
│ │ ├── transport.go
│ │ └── transport_test.go
│ ├── transport.go
│ └── transport_test.go
└── version.go
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/FUNDING.yml
================================================
open_collective: go-kratos
github: [go-kratos]
================================================
FILE: .github/ISSUE_TEMPLATE/bug-report.md
================================================
---
name: "\U0001F41B Bug Report"
about: Report something that's broken. Please ensure your kratos version is still supported.
title: ''
labels: bug
assignees: ''
---
<!--
Please answer these questions before submitting your issue. Thanks!
For questions please use one of our forums: https://go-kratos.dev/docs/getting-started/faq
-->
#### What happened:
#### What you expected to happen:
#### How to reproduce it (as minimally and precisely as possible):
#### Anything else we need to know?:
#### Environment:
- Kratos version (use `kratos -v`):
- Go version (use `go version`):
- OS (e.g: `cat /etc/os-release`):
- Others:
================================================
FILE: .github/ISSUE_TEMPLATE/config.yml
================================================
blank_issues_enabled: false
contact_links:
- name: Documentation issue
url: https://go-kratos.dev/docs/
about: For documentation issues, open a pull request at the go-kratos/go-kratos.dev repository
================================================
FILE: .github/ISSUE_TEMPLATE/feature-request.md
================================================
---
name: "\U0001F4A1 Feature Request"
about: For ideas or feature requests, start a new discussion.
title: "[Feature]"
labels: feature
assignees: ''
---
Please see the FAQ in our main README.md before submitting your issue.
<!--
In order to accurately distinguish that the needs put forward by users are the needs of most users and reasonable needs, solicit community opinions through the process, and the features adopted by the community will be realized as new functions.
In order to make the proposal process as simple as possible, the process includes three stages: feature request - > proposal - > pull-request, where feature, proposal is issue and pull-request is the specific function implementation.
### Feature-request
In order to help the community correctly understand the requirements of the feature, the feature request issue needs to describe the functional requirements and relevant references or documents in detail. And the feature request issue can contain the basic description of the function, which can be used as a reference for the function implementation in the proposal.
### Proposal
Proposal contains the basic implementation methods of functions, such as interface definition, general usage of functions, etc.
### Pull-request
After the function is realized, a merge request will be initiated to associate the proposal issue with the function issue. After the merger is completed, all questions will be closed and the process will end.
### Decision process
When more than five maintainer members agree to implement the feature, a proposal issue will be created for detailed design. The status of the proposal is divided into: under discussion, finalized and abandoned. After reaching the final status, start specific implementation (PR can also be implemented synchronously during the discussion)
### Final decision maker mechanism
If the maintainer team members have major differences on a requirement, the final decision is made by @Terry Mao.
-->
### What problem is the feature used to solve?
<!--
example:
We hope to add event interface to Kratos framework to access middleware such as Kafka and rabbitmq
-->
### Requirements description of the feature
<!--
example:
The event interface should be added to Kratos. The interface should contain subscribers and publishers, and the message body should contain key value head
-->
### References
<!--
example:
- [nats](http://xxxxx)
- [kafka](http://xxxxx)
- [rabbitmq](http://xxxxx)
-->
================================================
FILE: .github/ISSUE_TEMPLATE/proposal.md
================================================
---
name: "\U0001F9F1 Proposal Request"
about: Implementation draft of feature.
title: "[Proposal]"
labels: proposal
assignees: ''
---
Please see the FAQ in our main README.md before submitting your issue.
<!--
In order to accurately distinguish that the needs put forward by users are the needs of most users and reasonable needs, solicit community opinions through the process, and the features adopted by the community will be realized as new functions.
In order to make the proposal process as simple as possible, the process includes three stages: feature request - > proposal - > pull-request, where feature, proposal is issue and pull-request is the specific function implementation.
### Feature-request
In order to help the community correctly understand the requirements of the feature, the feature request issue needs to describe the functional requirements and relevant references or documents in detail. And the feature request issue can contain the basic description of the function, which can be used as a reference for the function implementation in the proposal.
### Proposal
Proposal contains the basic implementation methods of functions, such as interface definition, general usage of functions, etc.
### Pull-request
After the function is realized, a merge request will be initiated to associate the proposal issue with the function issue. After the merger is completed, all questions will be closed and the process will end.
### Decision process
When more than five maintainer members agree to implement the feature, a proposal issue will be created for detailed design. The status of the proposal is divided into: under discussion, finalized and abandoned. After reaching the final status, start specific implementation (PR can also be implemented synchronously during the discussion)
### Final decision maker mechanism
If the maintainer team members have major differences on a requirement, the final decision is made by @Terry Mao.
-->
### Proposal description
<!--
example:
Add event interface for accessing message oriented middleware
-->
### Implementation mode
<!--
```go
example:
type Message interface {
Key() string
Value() []byte
Header() map[string]string
Ack() error
Nack() error
}
type Handler func(context.Context, Message) error
type Event interface {
Send(ctx context.Context, key string, value []byte]) error
Receive(ctx context.Context, handler Handler) error
Close() error
}
````
-->
### Usage demonstration
<!--
example:
```go
msg := kafka.NewMessage("kratos", []byte("hello world"), map[string]string{
"user": "kratos",
"phone": "123456",
})
err := sender.Send(context.Background(), msg)
```
-->
================================================
FILE: .github/ISSUE_TEMPLATE/question.md
================================================
---
name: "\U0001F680 Question"
about: Ask a question about Kratos.
title: "[Question]"
labels: question
assignees: ''
---
Please see the FAQ in our main README.md before submitting your issue.
================================================
FILE: .github/dependabot.yml
================================================
---
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
================================================
FILE: .github/pull_request_template.md
================================================
<!--
🎉 Thanks for sending a pull request to Kratos! Here are some tips for you:
1. If this is your first time contributing to Kratos, please read our contribution guide: https://go-kratos.dev/docs/community/contribution/
2. Ensure you have added or ran the appropriate tests and lint for your PR, please use `make lint` and `make test` before filing your PR, use `make clean` to tidy your go mod.
3. If the PR is unfinished, you may need to mark it as a WIP(Work In Progress) PR or Draft PR
4. Please use a semantic commits format title, such as `<type>[optional scope]: <description>`, see: https://go-kratos.dev/docs/community/contribution#type
5. at the same time, please note that similar work should be submitted in one PR as far as possible to reduce the workload of reviewers. Do not split a work into multiple PR unless it should.
-->
<!--
🎉 感谢您向 Kratos 发送 PR!以下是一些提示:
如果这是你第一次为 Kratos 贡献,请阅读我们的贡献指南:https://go-kratos.dev/zh-cn/docs/community/contribution/
2、确保您已经为您的 PR 添加或运行了适当的测试和lint,请在提交PR之前使用“make lint”和“make test”,使用“make clean”整理您的 go.mod。
3、如果 PR 未完成,您可能需要将其标记为 WIP(Work In Progress)PR 或 Draft PR
4、请使用语义提交格式标题,如“<类型>[可选范围]:<说明>`,请参阅:https://go-kratos.dev/zh-cn/docs/community/contribution/#type
5. 同时请注意,同类的工作请尽量在一个PR中提交,以减轻 review 者的工作负担,不要把一项工作拆分成很多个PR,除非它应该这样做。
-->
#### Description (what this PR does / why we need it):
<!--
* The description should include the motivation for this PR or contrast this with previous behavior
-->
#### Which issue(s) this PR fixes (resolves / be part of):
<!--
* Automatically closes linked issue when PR is merged.
* If your PR is not fully resolved the issue, please use `part of #<issue number>` instead.
Usage: `fixes/resolves #<issue number>`, or `fixes/resolves (paste link of issue)`.
-->
#### Other special notes for the reviewers:
<!--
* Some things that need extra attention for the reviewers
* Some additional notes, TODO list, etc.
-->
================================================
FILE: .github/semantic.yml
================================================
titleOnly: true
commitOnly: false
titleAndCommits: false
scopes:
- api
- cmd
- config
- contrib
- docs
- encoding
- hack
- internal
- log
- metadata
- metrics
- middleware
- registry
- selector
- third_party
- transport
types:
- deps
- feat
- fix
- docs
- style
- refactor
- perf
- test
- build
- ci
- chore
- revert
================================================
FILE: .github/stable.yml
================================================
daysUntilStale: 30
daysUntilClose: 3
exemptLabels:
- pinned
- security
- bug
staleLabel: wontfix
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
closeComment: true
================================================
FILE: .github/workflows/codeql-analysis.yml
================================================
name: "CodeQL"
on:
push:
branches: [ main, v1.0.x ]
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v6
- name: Initialize CodeQL
uses: github/codeql-action/init@v4
with:
languages: go
- name: CodeQL Analysis
uses: github/codeql-action/analyze@v4
================================================
FILE: .github/workflows/comment-check.yml
================================================
name: Non-English Comments Check
on:
pull_request_target:
types: [opened, synchronize, reopened]
branches:
- main
# workflow_dispatch:
jobs:
non-english-comments-check:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
env:
# Directories to be excluded
EXCLUDE_DIRS: ".git docs tests scripts assets node_modules build"
# Files to be excluded
EXCLUDE_FILES: ".md .txt .html .css .min.js .mdx"
steps:
- uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
# - name: Search for Non-English comments in the entire repository
# run: |
# set -e
# # Define the regex pattern to match Chinese characters
# pattern='[\p{Han}]'
# # Use find to get all files in the repository
# all_files=$(find . -type f)
# # Loop over each file in the repository
# for file in $all_files; do
# # Skip files in excluded directories
# skip_file=false
# for dir in ${EXCLUDE_DIRS}; do
# if [[ "$file" == ./$dir/* ]]; then
# skip_file=true
# break
# fi
# done
# # Skip files matching excluded patterns
# for file_pattern in ${EXCLUDE_FILES}; do
# if [[ "$file" == *$file_pattern ]]; then
# skip_file=true
# break
# fi
# done
# # If the file matches any exclude pattern, skip it
# if [ "$skip_file" = true ]; then
# continue
# fi
# # Use grep to find all comments containing Non-English characters in filtered files
# grep_output=$(grep -PnH "$pattern" "$file" || true)
# if [ -n "$grep_output" ]; then
# # Insert a tab after the line number, keeping the colon between the file path and line number
# formatted_output=$(echo "$grep_output" | sed 's/^\(.*:[0-9]\+\):/\1\t/')
# echo "$formatted_output" >> non_english_comments.txt # Save to file
# fi
# done
- name: Search for Non-English comments in PR diff files
run: |
set -e
# Define the regex pattern to match Chinese characters
pattern='[\p{Han}]'
# Get the list of files changed in this PR compared to the base branch
changed_files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
# Loop over each changed file
for file in $changed_files; do
# Skip files in excluded directories
skip_file=false
for dir in ${EXCLUDE_DIRS}; do
if [[ "$file" == ./$dir/* ]]; then
skip_file=true
break
fi
done
# Skip files matching excluded patterns
for file_pattern in ${EXCLUDE_FILES}; do
if [[ "$file" == *$file_pattern ]]; then
skip_file=true
break
fi
done
# If the file matches any exclude pattern, skip it
if [ "$skip_file" = true ]; then
continue
fi
# Use grep to find all comments containing Non-English characters in filtered files
grep_output=$(grep -PnH "$pattern" "$file" || true)
if [ -n "$grep_output" ]; then
# Insert a tab after the line number, keeping the colon between the file path and line number
formatted_output=$(echo "$grep_output" | sed 's/^\(.*:[0-9]\+\):/\1\t/')
echo "$formatted_output" >> non_english_comments.txt # Save to file
fi
done
- name: Store non-English comments in ENV
run: |
# Store the entire content of non_english_comments.txt into an environment variable
if [ -f non_english_comments.txt ]; then
NON_ENGLISH_COMMENTS=$(cat non_english_comments.txt)
echo "NON_ENGLISH_COMMENTS<<EOF" >> $GITHUB_ENV
echo "$NON_ENGLISH_COMMENTS" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
fi
- name: Output non-English comments if found
run: |
if [ -s non_english_comments.txt ]; then
echo "Non-English comments found in the following locations:"
cat non_english_comments.txt
exit 1 # terminate the workflow
else
echo "No Non-English comments found."
fi
- name: Find Comment
if: failure() && github.event_name != 'workflow_dispatch'
uses: peter-evans/find-comment@v4.0.0
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "kratos-ci-bot"
body-includes: Non-English comments were found in the following locations
- name: Comment on PR if errors found
if: failure() && github.event_name != 'workflow_dispatch' # This step runs only if the previous step fails
uses: peter-evans/create-or-update-comment@v5.0.0
with:
token: ${{ secrets.BOT_GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
body: |
⚠️ Non-English comments were found in the following locations:
```
${{ env.NON_ENGLISH_COMMENTS }}
```
================================================
FILE: .github/workflows/gitee-sync.yml
================================================
on:
push:
branches:
- main
tags:
- "*"
name: Sync to Gitee
jobs:
run:
name: Run
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v6
- name: Mirror Github to Gitee
uses: Yikun/hub-mirror-action@v1.5
with:
src: github/go-kratos
dst: gitee/go-kratos
dst_key: ${{ secrets.GITEE_PRIVATE_KEY }}
dst_token: ${{ secrets.GITEE_TOKEN }}
account_type: org
timeout: 600
debug: true
force_update: true
static_list: "kratos"
================================================
FILE: .github/workflows/go.yml
================================================
name: Go
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
jobs:
build:
strategy:
matrix:
go: [1.22.x, 1.23.x, 1.24.x, 1.25.x]
name: build & test
runs-on: ubuntu-latest
services:
etcd:
image: gcr.io/etcd-development/etcd:v3.5.0
ports:
- 2379:2379
env:
ETCD_LISTEN_CLIENT_URLS: http://0.0.0.0:2379
ETCD_ADVERTISE_CLIENT_URLS: http://0.0.0.0:2379
consul:
image: hashicorp/consul:1.20
ports:
- 8500:8500
nacos:
image: nacos/nacos-server:v2.1.0
env:
MODE: standalone
ports:
- "8848:8848"
- "9848:9848"
polaris:
image: polarismesh/polaris-standalone:latest
ports:
- 8090:8090
- 8091:8091
- 8093:8093
steps:
- uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go }}
- name: Setup Environment
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Module cache
uses: actions/cache@v5
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go
- name: Build
run: go build ./...
env:
GOTOOLCHAIN: auto
- name: Test
run: make test-coverage
env:
GOTOOLCHAIN: auto
- name: Upload coverage to Codecov
run: bash <(curl -s https://codecov.io/bash)
- name: Kratos
run: |
cd cmd/kratos
go build ./...
env:
GOTOOLCHAIN: auto
- name: HTTP
run: |
cd cmd/protoc-gen-go-http
go build ./...
go test ./...
env:
GOTOOLCHAIN: auto
================================================
FILE: .github/workflows/issue-translator.yml
================================================
name: 'issue-translator'
on:
issue_comment:
types: [created]
issues:
types: [opened]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: usthe/issues-translate-action@v2.7
with:
IS_MODIFY_TITLE: true
CUSTOM_BOT_NOTE: Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑🤝🧑👫🧑🏿🤝🧑🏻👩🏾🤝👨🏿👬🏿
BOT_GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
================================================
FILE: .github/workflows/lint.yml
================================================
name: Lint
on:
push:
pull_request:
branches:
- main
workflow_dispatch:
jobs:
resolve-modules:
name: resolve module
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout Repo
uses: actions/checkout@v6
- id: set-matrix
run: ./hack/resolve-modules.sh
lint:
name: lint module
runs-on: ubuntu-latest
needs: resolve-modules
strategy:
matrix: ${{ fromJson(needs.resolve-modules.outputs.matrix) }}
steps:
- uses: actions/checkout@v6
- name: Lint
uses: golangci/golangci-lint-action@v7
with:
version: v2.0
working-directory: ${{ matrix.workdir }}
skip-pkg-cache: true
================================================
FILE: .gitignore
================================================
# Reference https://github.com/github/gitignore/blob/master/Go.gitignore
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.dylib
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
vendor/
# Go workspace file
go.work
go.work.sum
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# OS General
Thumbs.db
.DS_Store
.cache
# project
*.cert
*.key
*.log
bin/
# Develop tools
.vscode/
.idea/
*.swp
================================================
FILE: .golangci.yml
================================================
version: "2"
run:
modules-download-mode: readonly
linters:
default: none
enable:
- bodyclose
- dogsled
- durationcheck
- errcheck
- goconst
- gocyclo
- govet
- ineffassign
- lll
- misspell
- mnd
- prealloc
- revive
- staticcheck
- unconvert
- unused
- wastedassign
- whitespace
settings:
gocyclo:
min-complexity: 50
govet:
enable:
- shadow
lll:
line-length: 160
misspell:
locale: US
mnd:
checks:
- case
- condition
- return
whitespace:
multi-func: true
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
rules:
- linters:
- goconst
path: (.+)_test\.go
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- gofumpt
- goimports
settings:
goimports:
local-prefixes:
- github.com/go-kratos
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
================================================
FILE: CODE_OF_CONDUCT.md
================================================
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
iammao@vip.qq.com.
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series
of actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within
the community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.
================================================
FILE: CONTRIBUTING.md
================================================
The kratos community wants to be helped by a wide range of developers, so you'd like to take a few minutes to read this guide before you mention the problem or pull request.
## Reporting Bug or Fixing Bugs
We use GitHub issues to manage issues. If you want to submit , first make sure you've searched for existing issues, pull requests and read our [FAQ](https://go-kratos.dev/docs/intro/faq).
When submitting a bug report, use the issue template we provide to clearly describe the problems encountered and how to reproduce, and if convenient it is best to provide a minimal reproduce repository.
## Adding new features
In order to accurately distinguish whether the needs put forward by users are the needs or reasonable needs of most users, solicit opinions from the community through the proposal process, and the proposals adopted by the community will be realized as new feature.
In order to make the proposal process as simple as possible, the process includes three stages: proposal, feature and PR, in which proposal, feature is issue and PR is the specific function implementation.
In order to facilitate the community to correctly understand the requirements of the proposal, the proposal issue needs to describe the functional requirements and relevant references or literature in detail.
When most community users agree with this proposal, they will create a feature issue associated with the proposal issue.
The feature issue needs to describe the implementation method and function demonstration in detail as a reference for the final function implementation.
After the function is implemented, a merge request will be initiated to associate the proposal issue and feature issue.
After the merge is completed, Close all issues.
## How to submit code
If you've never submitted code on GitHub, follow these steps:
- First, please fork items to your GitHub account
- Then create a new feature branch based on the main branch and name it features such as feature-log
- Write code
- Submit code to the far end branch
- Submit a PR request in github
- Wait for review and merge to the main branch
**Note That when you submit a PR request, you first ensure that the code uses the correct coding specifications and that there are complete test cases, and that the information in the submission of the PR is best associated with the relevant issue to ease the workload of the auditor.**
## Conventional Commits
```
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
```
> More: [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/#summary)
### type
There are the following types of commit:
#### Main
- **fix**: A bug fix
- **feat**: A new feature
- **deps**: Changes external dependencies
- **break**: Changes has break change
#### Other
- **docs**: Documentation only changes
- **refactor**: A code change that neither fixes a bug nor adds a feature
- **style**: Changes that do not affect the meaning of the code (white-space, formatting, etc)
- **test**: Adding missing tests or correcting existing tests
- **chore** Daily work, examples, etc.
- **ci**: Changes to our CI configuration files and scripts
### scope
The following is the list of supported scopes:
- transport
- examples
- middleware
- config
- cmd
- etc.
### description
The description contains a succinct description of the change
- use the imperative, present tense: "change" not "changed" nor "changes"
- don't capitalize the first letter
- no dot (.) at the end
### body
The body should include the motivation for the change and contrast this with previous behavior.
### footer
The footer should contain any information about **Breaking Changes** and is also the place to reference GitHub issues that this commit Closes.
### examples
#### Only commit message
```
fix: The log debug level should be -1
```
#### Attention
```
refactor!(transport/http): replacement underlying implementation
```
#### Full commit message
```
fix(log): [BREAKING-CHANGE] unable to meet the requirement of log Library
Explain the reason, purpose, realization method, etc.
Close #777
Doc change on doc/#111
BREAKING CHANGE:
Breaks log.info api, log.log should be used instead
```
## Release
You can use `kratos changelog dev` to generate a change log during.
The following is the list of supported types:
- Breaking Change
- Dependencies
- Bug Fixes
- Others
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2020 go-kratos
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: Makefile
================================================
user := $(shell whoami)
rev := $(shell git rev-parse --short HEAD)
os := $(shell uname)
# GOBIN > GOPATH > INSTALLDIR
# Mac OS X
ifeq ($(os),Darwin)
GOBIN := $(shell echo $(GOBIN) | cut -d':' -f1)
GOPATH := $(shell echo $(GOPATH) | cut -d':' -f1)
endif
# Linux
ifeq ($(os),Linux)
GOBIN := $(shell echo $(GOBIN) | cut -d':' -f1)
GOPATH := $(shell echo $(GOPATH) | cut -d':' -f1)
endif
# Windows
ifneq ($(findstring MINGW,$(shell uname -s)),)
GOBIN := $(shell echo "$(GOBIN)" | sed 's|\\|/|g' | cut -d';' -f1 | sed 's|^\([A-Za-z]\):|/\1|')
GOPATH := $(shell echo "$(GOPATH)" | sed 's|\\|/|g' | cut -d';' -f1 | sed 's|^\([A-Za-z]\):|/\1|')
endif
BIN := ""
TOOLS_SHELL="./hack/tools.sh"
# golangci-lint
LINTER := bin/golangci-lint
# check GOBIN
ifneq ($(GOBIN),)
BIN=$(GOBIN)
else
# check GOPATH
ifneq ($(GOPATH),)
BIN=$(GOPATH)/bin
endif
endif
$(LINTER):
curl -SL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s latest
all:
@cd cmd/kratos && go build && cd - &> /dev/null
@cd cmd/protoc-gen-go-errors && go build && cd - &> /dev/null
@cd cmd/protoc-gen-go-http && go build && cd - &> /dev/null
.PHONY: install
install: all
ifeq ($(user),root)
#root, install for all user
@cp ./cmd/kratos/kratos /usr/bin
@cp ./cmd/protoc-gen-go-errors/protoc-gen-go-errors /usr/bin
@cp ./cmd/protoc-gen-go-http/protoc-gen-go-http /usr/bin
else
#!root, install for current user
$(shell if [ -z '$(BIN)' ]; then read -p "Please select installdir: " REPLY; mkdir -p $${REPLY};\
cp ./cmd/kratos/kratos $${REPLY}/;cp ./cmd/protoc-gen-go-errors/protoc-gen-go-errors $${REPLY}/;cp ./cmd/protoc-gen-go-http/protoc-gen-go-http $${REPLY}/;else mkdir -p '$(BIN)';\
cp ./cmd/kratos/kratos '$(BIN)';cp ./cmd/protoc-gen-go-errors/protoc-gen-go-errors '$(BIN)';cp ./cmd/protoc-gen-go-http/protoc-gen-go-http '$(BIN)'; fi)
endif
@which protoc-gen-go &> /dev/null || go get google.golang.org/protobuf/cmd/protoc-gen-go
@which protoc-gen-go-grpc &> /dev/null || go get google.golang.org/grpc/cmd/protoc-gen-go-grpc
@which protoc-gen-validate &> /dev/null || go get github.com/envoyproxy/protoc-gen-validate
@echo "install finished"
.PHONY: uninstall
uninstall:
$(shell for i in `which -a kratos | grep -v '/usr/bin/kratos' 2>/dev/null | sort | uniq`; do read -p "Press to remove $${i} (y/n): " REPLY; if [ $${REPLY} = "y" ]; then rm -f $${i}; fi; done)
$(shell for i in `which -a protoc-gen-go-grpc | grep -v '/usr/bin/protoc-gen-go-errors' 2>/dev/null | sort | uniq`; do read -p "Press to remove $${i} (y/n): " REPLY; if [ $${REPLY} = "y" ]; then rm -f $${i}; fi; done)
$(shell for i in `which -a protoc-gen-validate | grep -v '/usr/bin/protoc-gen-go-errors' 2>/dev/null | sort | uniq`; do read -p "Press to remove $${i} (y/n): " REPLY; if [ $${REPLY} = "y" ]; then rm -f $${i}; fi; done)
@echo "uninstall finished"
.PHONY: clean
clean:
@${TOOLS_SHELL} tidy
@echo "clean finished"
.PHONY: fix
fix: $(LINTER)
@${TOOLS_SHELL} fix
@echo "lint fix finished"
.PHONY: test
test:
@${TOOLS_SHELL} test
@echo "go test finished"
.PHONY: test-coverage
test-coverage:
@${TOOLS_SHELL} test_coverage
@echo "go test with coverage finished"
.PHONY: lint
lint: $(LINTER)
@${TOOLS_SHELL} lint
@echo "lint check finished"
.PHONY: proto
proto:
protoc --proto_path=./api --proto_path=./third_party --go_out=paths=source_relative:./api --go-grpc_out=paths=source_relative:./api --go-http_out=paths=source_relative:./api metadata/metadata.proto
protoc --proto_path=./third_party --go_out=paths=source_relative:./errors/errors.proto
================================================
FILE: README.md
================================================
<p align="center"><a href="https://go-kratos.dev/" target="_blank"><img src="https://github.com/go-kratos/kratos/blob/main/docs/images/kratos-large.png?raw=true"></a></p>
<p align="center">
<a href="https://github.com/go-kratos/kratos/actions"><img src="https://github.com/go-kratos/kratos/workflows/Go/badge.svg" alt="Build Status"></a>
<a href="https://pkg.go.dev/github.com/go-kratos/kratos/v2"><img src="https://pkg.go.dev/badge/github.com/go-kratos/kratos/v2" alt="GoDoc"></a>
<a href="https://deepwiki.com/go-kratos/kratos"><img src="https://img.shields.io/badge/DeepWiki-go--kratos%2Fkratos-blue.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAyCAYAAAAnWDnqAAAAAXNSR0IArs4c6QAAA05JREFUaEPtmUtyEzEQhtWTQyQLHNak2AB7ZnyXZMEjXMGeK/AIi+QuHrMnbChYY7MIh8g01fJoopFb0uhhEqqcbWTp06/uv1saEDv4O3n3dV60RfP947Mm9/SQc0ICFQgzfc4CYZoTPAswgSJCCUJUnAAoRHOAUOcATwbmVLWdGoH//PB8mnKqScAhsD0kYP3j/Yt5LPQe2KvcXmGvRHcDnpxfL2zOYJ1mFwrryWTz0advv1Ut4CJgf5uhDuDj5eUcAUoahrdY/56ebRWeraTjMt/00Sh3UDtjgHtQNHwcRGOC98BJEAEymycmYcWwOprTgcB6VZ5JK5TAJ+fXGLBm3FDAmn6oPPjR4rKCAoJCal2eAiQp2x0vxTPB3ALO2CRkwmDy5WohzBDwSEFKRwPbknEggCPB/imwrycgxX2NzoMCHhPkDwqYMr9tRcP5qNrMZHkVnOjRMWwLCcr8ohBVb1OMjxLwGCvjTikrsBOiA6fNyCrm8V1rP93iVPpwaE+gO0SsWmPiXB+jikdf6SizrT5qKasx5j8ABbHpFTx+vFXp9EnYQmLx02h1QTTrl6eDqxLnGjporxl3NL3agEvXdT0WmEost648sQOYAeJS9Q7bfUVoMGnjo4AZdUMQku50McDcMWcBPvr0SzbTAFDfvJqwLzgxwATnCgnp4wDl6Aa+Ax283gghmj+vj7feE2KBBRMW3FzOpLOADl0Isb5587h/U4gGvkt5v60Z1VLG8BhYjbzRwyQZemwAd6cCR5/XFWLYZRIMpX39AR0tjaGGiGzLVyhse5C9RKC6ai42ppWPKiBagOvaYk8lO7DajerabOZP46Lby5wKjw1HCRx7p9sVMOWGzb/vA1hwiWc6jm3MvQDTogQkiqIhJV0nBQBTU+3okKCFDy9WwferkHjtxib7t3xIUQtHxnIwtx4mpg26/HfwVNVDb4oI9RHmx5WGelRVlrtiw43zboCLaxv46AZeB3IlTkwouebTr1y2NjSpHz68WNFjHvupy3q8TFn3Hos2IAk4Ju5dCo8B3wP7VPr/FGaKiG+T+v+TQqIrOqMTL1VdWV1DdmcbO8KXBz6esmYWYKPwDL5b5FA1a0hwapHiom0r/cKaoqr+27/XcrS5UwSMbQAAAABJRU5ErkJggg==" alt="DeepWiki"></a>
<!-- DeepWiki badge generated by https://deepwiki.ryoppippi.com/ -->
<a href="https://codecov.io/gh/go-kratos/kratos"><img src="https://codecov.io/gh/go-kratos/kratos/master/graph/badge.svg" alt="codeCov"></a>
<a href="https://goreportcard.com/report/github.com/go-kratos/kratos"><img src="https://goreportcard.com/badge/github.com/go-kratos/kratos" alt="Go Report Card"></a>
<a href="https://github.com/go-kratos/kratos/blob/main/LICENSE"><img src="https://img.shields.io/github/license/go-kratos/kratos" alt="License"></a>
<a href="https://github.com/avelino/awesome-go"><img src="https://awesome.re/mentioned-badge.svg" alt="Awesome Go"></a>
<a href="https://discord.gg/BWzJsUJ"><img src="https://img.shields.io/discord/766619759214854164?label=chat&logo=discord" alt="Discord"></a>
</p>
<p align="center">
<a href="https://trendshift.io/repositories/3233" target="_blank"><img src="https://trendshift.io/api/badge/repositories/3233" alt="go-kratos%2Fkratos | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
<a href="https://www.producthunt.com/posts/go-kratos?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-go-kratos" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=306565&theme=light" alt="Go Kratos - A Go framework for microservices. | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
</p>
##### Translate to: [简体中文](README_zh.md)
## About Kratos
> The name is inspired by the Greek-mythology-based game "God of War". It tells the adventures of Kratos becoming a god of war from a mortal and launching a god-killing slaughter.
Kratos is a microservice-oriented governance framework implemented by golang, which offers convenient capabilities to help you quickly build a bulletproof application from scratch, such as:
- The [communication protocol](https://go-kratos.dev/docs/component/api) is based on the HTTP/gRPC through the definition of Protobuf.
- Abstract [transport](https://go-kratos.dev/docs/component/transport/overview) layer support: [HTTP](https://go-kratos.dev/docs/component/transport/http) / [gRPC](https://go-kratos.dev/docs/component/transport/grpc).
- Powerful [middleware](https://go-kratos.dev/docs/component/middleware/overview) design, support: [Tracing (OpenTelemetry)](https://go-kratos.dev/docs/component/middleware/tracing), [Metrics (Prometheus is default)](https://go-kratos.dev/docs/component/middleware/metrics), [Recovery](https://go-kratos.dev/docs/component/middleware/recovery) and more.
- [Registry](https://go-kratos.dev/docs/component/registry) interface able to be connected with various other centralized registries through plug-ins.
- The [standard log interfaces](https://go-kratos.dev/docs/component/log) ease the integration of the third-party log libs with logs collected through the *Fluentd*.
- Automatically support the selection of the content [encoding](https://go-kratos.dev/docs/component/encoding) with Accept and Content-Type.
- Multiple data sources are supported for [configurations](https://go-kratos.dev/docs/component/config) and dynamic configurations (use atomic operations).
- In the protocol of HTTP/gRPC, use the uniform [metadata](https://go-kratos.dev/docs/component/metadata) transfer method.
- You can define [errors](https://go-kratos.dev/docs/component/errors/) in protos and generate enums with protoc-gen-go.
- You can define [verification rules](https://go-kratos.dev/docs/component/middleware/validate) in Protobuf supported by the HTTP/gRPC service.
- [Swagger API](https://go-kratos.dev/docs/guide/openapi) is generated Automatically and embed Swagger UI endpoint can be started by adding [Swagger plugin](https://github.com/go-kratos/swagger-api).
Kratos is accessible, powerful, and provides tools required for large, robust applications.
## Learning Kratos
Kratos has the most extensive and thorough [documentation](https://go-kratos.dev/docs/getting-started/start) and [example](https://github.com/go-kratos/examples) library of all modern web application frameworks, making it a breeze to get started with the framework.
We also provide a [modern template](https://github.com/go-kratos/kratos-layout). This template should help reduce the work required to set up modern projects.
### Goals
Kratos boosts your productivity. With the integration of excellent resources and further support, programmers can get rid of most issues might encounter in the field of distributed systems and software engineering such that they are allowed to focus on the release of businesses only. Additionally, for each programmer, Kratos is also an ideal one learning warehouse for many aspects of microservices to enrich their experiences and skills.
### Principles
* **Simple**: Appropriate design with plain and easy code.
* **General**: Cover the various utilities for business development.
* **Highly efficient**: Speeding up the efficiency of businesses upgrading.
* **Stable**: The base libs validated in the production environment have the characteristics of high testability, high coverage as well as high security and reliability.
* **Robust**: Eliminating misusing through high quality of the base libs.
* **High-performance**: Optimal performance excluding the optimization of hacking in case of *unsafe*.
* **Expandability**: Properly designed interfaces where you can expand utilities such as base libs to meet your further requirements.
* **Fault-tolerance**: Designed against failure, enhance the understanding and exercising of SRE within Kratos to achieve more robustness.
* **Toolchain**: Includes an extensive toolchain, such as the code generation of cache, the lint tool, and so forth.
## Getting Started
Create a kratos playground through [docker](https://www.docker.com/products/docker-desktop):
```shell
docker run -it --rm -p 8000:8000 --workdir /workspace golang
```
```shell
apt-get update && apt-get -y install protobuf-compiler
export GOPROXY=https://goproxy.io,direct
go install github.com/go-kratos/kratos/cmd/kratos/v2@latest && kratos upgrade
```
```shell
kratos new helloworld
cd helloworld/ && go mod tidy
kratos run
```
Use a browser to open and visit: `http://localhost:8000/helloworld/kratos`, The kratos program is running!
If you need more, please visit the kratos [documentation](https://go-kratos.dev/docs/getting-started/start).
## Security Vulnerabilities
If you discover a security vulnerability within Kratos, please send an e-mail to tonybase via go-kratos@googlegroups.com. All security vulnerabilities will be promptly addressed.
## Community
- [Wechat Group](https://github.com/go-kratos/kratos/issues/682)
- [Discord Group](https://discord.gg/BWzJsUJ)
- [go-kratos.dev](https://go-kratos.dev/en)
## Contributors
Thank you for considering contributing to the Kratos framework! The contribution guide can be found in the [Kratos documentation](https://go-kratos.dev/docs/community/contribution).
<a href="https://github.com/go-kratos/kratos/graphs/contributors">
<img src="https://contrib.rocks/image?repo=go-kratos/kratos" />
</a>
## License
The Kratos framework is open-sourced software licensed under the [MIT license](./LICENSE).
## Acknowledgments
The following project had particular influence on kratos's design.
- [go-kit/kit](https://github.com/go-kit/kit) is a programming toolkit for building microservices in go.
- [asim/go-micro](https://github.com/asim/go-micro) a distributed systems development framework.
- [google/go-cloud](https://github.com/google/go-cloud) is go cloud development kit.
- [zeromicro/go-zero](https://github.com/zeromicro/go-zero) is a web and rpc framework with lots of builtin engineering practices.
- [beego/beego](https://github.com/beego/beego) is a web framework including RESTful APIs, web apps and backend services.
================================================
FILE: README_zh.md
================================================
<p align="center"><a href="https://go-kratos.dev/" target="_blank"><img src="https://github.com/go-kratos/kratos/blob/main/docs/images/kratos-large.png?raw=true"></a></p>
<p align="center">
<a href="https://github.com/go-kratos/kratos/actions"><img src="https://github.com/go-kratos/kratos/workflows/Go/badge.svg" alt="Build Status"></a>
<a href="https://pkg.go.dev/github.com/go-kratos/kratos/v2"><img src="https://pkg.go.dev/badge/github.com/go-kratos/kratos/v2" alt="GoDoc"></a>
<a href="https://codecov.io/gh/go-kratos/kratos"><img src="https://codecov.io/gh/go-kratos/kratos/master/graph/badge.svg" alt="codeCov"></a>
<a href="https://goreportcard.com/report/github.com/go-kratos/kratos"><img src="https://goreportcard.com/badge/github.com/go-kratos/kratos" alt="Go Report Card"></a>
<a href="https://github.com/go-kratos/kratos/blob/main/LICENSE"><img src="https://img.shields.io/github/license/go-kratos/kratos" alt="License"></a>
<a href="https://github.com/avelino/awesome-go"><img src="https://awesome.re/mentioned-badge.svg" alt="Awesome Go"></a>
<a href="https://discord.gg/BWzJsUJ"><img src="https://img.shields.io/discord/766619759214854164?label=chat&logo=discord" alt="Discord"></a>
</p>
<p align="center">
<a href="https://trendshift.io/repositories/3233" target="_blank"><img src="https://trendshift.io/api/badge/repositories/3233" alt="go-kratos%2Fkratos | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
<a href="https://www.producthunt.com/posts/go-kratos?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-go-kratos" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=306565&theme=light" alt="Go Kratos - A Go framework for microservices. | Product Hunt" style="width: 250px; height: 54px;" width="250" height="54" /></a>
</p>
Translations: [English](README.md) | [简体中文](README_zh.md)
# Kratos
Kratos 一套轻量级 Go 微服务框架,包含大量微服务相关功能及工具。
> 名字来源于:《战神》游戏以希腊神话为背景,讲述奎托斯(Kratos)由凡人成为战神并展开弑神屠杀的冒险经历。
## Goals
我们致力于提供完整、全面的微服务研发体验,通过整合相关框架和工具,微服务治理部分能够无缝融入整个业务开发周期,使开发者更加专注于业务交付。
对每位开发者而言,Kratos 是非常不错的学习仓库,可以了解和参考微服务领域的技术积累和经验。
### Principles
* 简单:不过度设计,代码平实简单;
* 通用:通用业务开发所需要的基础库的功能;
* 高效:提高业务迭代的效率;
* 稳定:基础库可测试性高,覆盖率高,有线上实践安全可靠;
* 健壮:通过良好的基础库设计,减少错用;
* 高性能:性能高,但不特定为了性能做 hack 优化,引入 unsafe ;
* 扩展性:良好的接口设计,来扩展实现,或者通过新增基础库目录来扩展功能;
* 容错性:为失败设计,大量引入对 SRE 的理解,鲁棒性高;
* 工具链:包含大量工具链,比如 cache 代码生成,lint 工具等等。
## Features
* [APIs](https://go-kratos.dev/zh-cn/docs/component/api) :协议通信以 HTTP/gRPC 为基础,通过 Protobuf 进行定义;
* [Errors](https://go-kratos.dev/zh-cn/docs/component/errors/) :通过 Protobuf 的 Enum 作为错误码定义,以及工具生成判定接口;
* [Metadata](https://go-kratos.dev/zh-cn/docs/component/metadata) :在协议通信 HTTP/gRPC 中,通过 Middleware 规范化服务元信息传递;
* [Config](https://go-kratos.dev/zh-cn/docs/component/config) :支持多数据源方式,进行配置合并铺平,通过 Atomic 方式支持动态配置;
* [Logger](https://go-kratos.dev/zh-cn/docs/component/log) :标准日志接口,可方便集成三方 log 库,并可通过 fluentd 收集日志;
* [Metrics](https://go-kratos.dev/zh-cn/docs/component/middleware/metrics) :统一指标接口,可以实现各种指标系统,默认集成 Prometheus;
* [Tracing](https://go-kratos.dev/zh-cn/docs/component/middleware/tracing) :遵循 OpenTelemetry 规范定义,以实现微服务链路追踪;
* [Encoding](https://go-kratos.dev/zh-cn/docs/component/encoding) :支持 Accept 和 Content-Type 进行自动选择内容编码;
* [Transport](https://go-kratos.dev/zh-cn/docs/component/transport/overview) :通用的 [HTTP](https://go-kratos.dev/zh-cn/docs/component/transport/http) /[gRPC](https://go-kratos.dev/zh-cn/docs/component/transport/grpc) 传输层,实现统一的 [Middleware](https://go-kratos.dev/zh-cn/docs/component/middleware/overview) 插件支持;
* [Registry](https://go-kratos.dev/zh-cn/docs/component/registry) :实现统一注册中心接口,可插件化对接各种注册中心;
* [Validation](https://go-kratos.dev/zh-cn/docs/component/middleware/validate): 通过 Protobuf 统一定义校验规则,并同时适用于 HTTP/gRPC 服务;
* [SwaggerAPI](https://go-kratos.dev/zh-cn/docs/guide/openapi): 通过集成第三方 [Swagger 插件](https://github.com/go-kratos/swagger-api) 能够自动生成 Swagger API 文档并启动内置的 Swagger UI服 务。
## Getting Started
### Required
- [go](https://golang.org/dl/)
- [protoc](https://github.com/protocolbuffers/protobuf)
- [protoc-gen-go](https://github.com/protocolbuffers/protobuf-go)
### Installing
##### go install 安装:
```
go install github.com/go-kratos/kratos/cmd/kratos/v2@latest
kratos upgrade
```
##### 源码编译安装:
```
git clone https://github.com/go-kratos/kratos
cd kratos
make install
```
### Create a service
```
# 创建项目模板
kratos new helloworld
cd helloworld
# 拉取项目依赖
go mod download
# 生成 proto 模板
kratos proto add api/helloworld/helloworld.proto
# 生成 proto 源码
kratos proto client api/helloworld/helloworld.proto
# 生成 server 模板
kratos proto server api/helloworld/helloworld.proto -t internal/service
# 生成所有 proto 源码、wire 等等
go generate ./...
# 运行程序
kratos run
```
### Kratos Boot
```
import "github.com/go-kratos/kratos/v2"
import "github.com/go-kratos/kratos/v2/transport/grpc"
import "github.com/go-kratos/kratos/v2/transport/http"
httpSrv := http.NewServer(http.Address(":8000"))
grpcSrv := grpc.NewServer(grpc.Address(":9000"))
app := kratos.New(
kratos.Name("kratos"),
kratos.Version("latest"),
kratos.Server(httpSrv, grpcSrv),
)
app.Run()
```
## Related
* [Docs](https://go-kratos.dev/)
* [Examples](https://github.com/go-kratos/examples)
* [Service Layout](https://github.com/go-kratos/kratos-layout)
## Community
* [Wechat Group](https://github.com/go-kratos/kratos/issues/682)
* [Discord Group](https://discord.gg/BWzJsUJ)
* Website: [go-kratos.dev](https://go-kratos.dev)
* QQ Group: 716486124
## WeChat Official Account

## Conventional commits
提交信息的结构应该如下所示:
```text
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
```
提交信息应按照下面的格式:
- fix: simply describe the problem that has been fixed
- feat(log): simple describe of new features
- deps(examples): simple describe the change of the dependency
- break(http): simple describe the reasons for breaking change
## Sponsors and Backers

## License
Kratos is MIT licensed. See the [LICENSE](./LICENSE) file for details.
================================================
FILE: ROADMAP.md
================================================
# Kratos
This document defines the roadmap for Kratos development.
## Features
- [x] Config
- [x] Local Files
- [x] K8s ConfigMap
- [x] Consul
- [x] Etcd
- [x] Nacos
- [x] Registry
- [x] Consul
- [x] Etcd
- [x] K8s
- [x] Nacos
- [x] Encoding
- [x] JSON
- [x] Protobuf
- [x] Transport
- [x] HTTP
- [x] gRPC
- [x] Middleware
- [x] Logging
- [x] metrics
- [x] recovery
- [x] gRPC status
- [x] transport tracing
- [x] Validator
- [x] Authentication
- [x] Ratelimit
- [x] CircuitBreaker
- [x] Metrics
- [x] Prometheus
- [x] DataDog
- [x] Tracing
- [x] HTTP
- [x] TLS
- [x] Client
- [x] Service Registrar
- [ ] javascript/typescript clients
- [x] gRPC
- [x] TLS
- [x] Unary Handler
- [x] Streaming Handler
- [ ] Cache
- [ ] go-redis
- [x] Event
- [x] Pub/Sub
- [x] Kafka
- [ ] Nats
- [x] Database
- [x] Ent
- [ ] Gorm
## Platform
- [ ] Kratos API
- [ ] Auth
- [ ] Config
- [ ] Registry
- [ ] Events
- [ ] Kratos Runtime
- [ ] Secrets
- [ ] Service-to-Service
- [ ] Publish and Subscribe
- [ ] Observability
- [ ] Controllable
- [ ] Kratos UI
- [ ] Auth
- [ ] Config
- [ ] Services
- [ ] Endpoints
- [ ] Ratelimit
- [ ] CircuitBreaker
- [ ] FaultInjection
- [ ] TrafficPolicy
## Tools
- [x] Kratos
- [x] HTTP Generator
- [ ] API YAML
- [x] Errors Generator
================================================
FILE: SECURITY.md
================================================
# Security Policy
## Supported Versions
Use this section to tell people about which versions of your project are
currently being supported with security updates.
| Version | Supported |
|-------------|--------------------|
| 2.0.rc1 | :white_check_mark: |
| < 2.0.beta3 | :x: |
## Reporting a Vulnerability
Use this section to tell people how to report a vulnerability.
Tell them where to go, how often they can expect to get an update on a
reported vulnerability, what to expect if the vulnerability is accepted or
declined, etc.
================================================
FILE: api/README.md
================================================
# API proto
================================================
FILE: api/metadata/metadata.pb.go
================================================
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.28.0
// protoc v3.19.4
// source: metadata/metadata.proto
package metadata
import (
_ "google.golang.org/genproto/googleapis/api/annotations"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
descriptorpb "google.golang.org/protobuf/types/descriptorpb"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type ListServicesRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
}
func (x *ListServicesRequest) Reset() {
*x = ListServicesRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_metadata_metadata_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListServicesRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListServicesRequest) ProtoMessage() {}
func (x *ListServicesRequest) ProtoReflect() protoreflect.Message {
mi := &file_metadata_metadata_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListServicesRequest.ProtoReflect.Descriptor instead.
func (*ListServicesRequest) Descriptor() ([]byte, []int) {
return file_metadata_metadata_proto_rawDescGZIP(), []int{0}
}
type ListServicesReply struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Services []string `protobuf:"bytes,1,rep,name=services,proto3" json:"services,omitempty"`
Methods []string `protobuf:"bytes,2,rep,name=methods,proto3" json:"methods,omitempty"`
}
func (x *ListServicesReply) Reset() {
*x = ListServicesReply{}
if protoimpl.UnsafeEnabled {
mi := &file_metadata_metadata_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListServicesReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListServicesReply) ProtoMessage() {}
func (x *ListServicesReply) ProtoReflect() protoreflect.Message {
mi := &file_metadata_metadata_proto_msgTypes[1]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListServicesReply.ProtoReflect.Descriptor instead.
func (*ListServicesReply) Descriptor() ([]byte, []int) {
return file_metadata_metadata_proto_rawDescGZIP(), []int{1}
}
func (x *ListServicesReply) GetServices() []string {
if x != nil {
return x.Services
}
return nil
}
func (x *ListServicesReply) GetMethods() []string {
if x != nil {
return x.Methods
}
return nil
}
type GetServiceDescRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
}
func (x *GetServiceDescRequest) Reset() {
*x = GetServiceDescRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_metadata_metadata_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetServiceDescRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetServiceDescRequest) ProtoMessage() {}
func (x *GetServiceDescRequest) ProtoReflect() protoreflect.Message {
mi := &file_metadata_metadata_proto_msgTypes[2]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetServiceDescRequest.ProtoReflect.Descriptor instead.
func (*GetServiceDescRequest) Descriptor() ([]byte, []int) {
return file_metadata_metadata_proto_rawDescGZIP(), []int{2}
}
func (x *GetServiceDescRequest) GetName() string {
if x != nil {
return x.Name
}
return ""
}
type GetServiceDescReply struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
FileDescSet *descriptorpb.FileDescriptorSet `protobuf:"bytes,1,opt,name=file_desc_set,json=fileDescSet,proto3" json:"file_desc_set,omitempty"`
}
func (x *GetServiceDescReply) Reset() {
*x = GetServiceDescReply{}
if protoimpl.UnsafeEnabled {
mi := &file_metadata_metadata_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *GetServiceDescReply) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*GetServiceDescReply) ProtoMessage() {}
func (x *GetServiceDescReply) ProtoReflect() protoreflect.Message {
mi := &file_metadata_metadata_proto_msgTypes[3]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use GetServiceDescReply.ProtoReflect.Descriptor instead.
func (*GetServiceDescReply) Descriptor() ([]byte, []int) {
return file_metadata_metadata_proto_rawDescGZIP(), []int{3}
}
func (x *GetServiceDescReply) GetFileDescSet() *descriptorpb.FileDescriptorSet {
if x != nil {
return x.FileDescSet
}
return nil
}
var File_metadata_metadata_proto protoreflect.FileDescriptor
var file_metadata_metadata_proto_rawDesc = []byte{
0x0a, 0x17, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x6d, 0x65, 0x74, 0x61, 0x64,
0x61, 0x74, 0x61, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x6b, 0x72, 0x61, 0x74, 0x6f,
0x73, 0x2e, 0x61, 0x70, 0x69, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x6f,
0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f,
0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x15, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x72,
0x76, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x49, 0x0a, 0x11,
0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x70, 0x6c,
0x79, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20,
0x03, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x12, 0x18, 0x0a,
0x07, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07,
0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x73, 0x22, 0x2b, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x53, 0x65,
0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, 0x73, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
0x6e, 0x61, 0x6d, 0x65, 0x22, 0x5d, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69,
0x63, 0x65, 0x44, 0x65, 0x73, 0x63, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x46, 0x0a, 0x0d, 0x66,
0x69, 0x6c, 0x65, 0x5f, 0x64, 0x65, 0x73, 0x63, 0x5f, 0x73, 0x65, 0x74, 0x18, 0x01, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x22, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x62, 0x75, 0x66, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70,
0x74, 0x6f, 0x72, 0x53, 0x65, 0x74, 0x52, 0x0b, 0x66, 0x69, 0x6c, 0x65, 0x44, 0x65, 0x73, 0x63,
0x53, 0x65, 0x74, 0x32, 0xdd, 0x01, 0x0a, 0x08, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61,
0x12, 0x61, 0x0a, 0x0c, 0x4c, 0x69, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73,
0x12, 0x1f, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4c, 0x69,
0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x1d, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x4c,
0x69, 0x73, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x52, 0x65, 0x70, 0x6c, 0x79,
0x22, 0x11, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0b, 0x12, 0x09, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69,
0x63, 0x65, 0x73, 0x12, 0x6e, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63,
0x65, 0x44, 0x65, 0x73, 0x63, 0x12, 0x21, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61,
0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x44, 0x65, 0x73,
0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f,
0x73, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x47, 0x65, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
0x44, 0x65, 0x73, 0x63, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x18, 0x82, 0xd3, 0xe4, 0x93, 0x02,
0x12, 0x12, 0x10, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x7b, 0x6e, 0x61,
0x6d, 0x65, 0x7d, 0x42, 0x63, 0x0a, 0x15, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x69, 0x74, 0x68, 0x75,
0x62, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x61, 0x70, 0x69, 0x50, 0x01, 0x5a, 0x3c,
0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x2d, 0x6b, 0x72,
0x61, 0x74, 0x6f, 0x73, 0x2f, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2f, 0x76, 0x32, 0x2f, 0x61,
0x70, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2f,
0x61, 0x70, 0x69, 0x3b, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xa2, 0x02, 0x09, 0x4b,
0x72, 0x61, 0x74, 0x6f, 0x73, 0x41, 0x50, 0x49, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_metadata_metadata_proto_rawDescOnce sync.Once
file_metadata_metadata_proto_rawDescData = file_metadata_metadata_proto_rawDesc
)
func file_metadata_metadata_proto_rawDescGZIP() []byte {
file_metadata_metadata_proto_rawDescOnce.Do(func() {
file_metadata_metadata_proto_rawDescData = protoimpl.X.CompressGZIP(file_metadata_metadata_proto_rawDescData)
})
return file_metadata_metadata_proto_rawDescData
}
var file_metadata_metadata_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_metadata_metadata_proto_goTypes = []interface{}{
(*ListServicesRequest)(nil), // 0: kratos.api.ListServicesRequest
(*ListServicesReply)(nil), // 1: kratos.api.ListServicesReply
(*GetServiceDescRequest)(nil), // 2: kratos.api.GetServiceDescRequest
(*GetServiceDescReply)(nil), // 3: kratos.api.GetServiceDescReply
(*descriptorpb.FileDescriptorSet)(nil), // 4: google.protobuf.FileDescriptorSet
}
var file_metadata_metadata_proto_depIdxs = []int32{
4, // 0: kratos.api.GetServiceDescReply.file_desc_set:type_name -> google.protobuf.FileDescriptorSet
0, // 1: kratos.api.Metadata.ListServices:input_type -> kratos.api.ListServicesRequest
2, // 2: kratos.api.Metadata.GetServiceDesc:input_type -> kratos.api.GetServiceDescRequest
1, // 3: kratos.api.Metadata.ListServices:output_type -> kratos.api.ListServicesReply
3, // 4: kratos.api.Metadata.GetServiceDesc:output_type -> kratos.api.GetServiceDescReply
3, // [3:5] is the sub-list for method output_type
1, // [1:3] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_metadata_metadata_proto_init() }
func file_metadata_metadata_proto_init() {
if File_metadata_metadata_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_metadata_metadata_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListServicesRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_metadata_metadata_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListServicesReply); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_metadata_metadata_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetServiceDescRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_metadata_metadata_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*GetServiceDescReply); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_metadata_metadata_proto_rawDesc,
NumEnums: 0,
NumMessages: 4,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_metadata_metadata_proto_goTypes,
DependencyIndexes: file_metadata_metadata_proto_depIdxs,
MessageInfos: file_metadata_metadata_proto_msgTypes,
}.Build()
File_metadata_metadata_proto = out.File
file_metadata_metadata_proto_rawDesc = nil
file_metadata_metadata_proto_goTypes = nil
file_metadata_metadata_proto_depIdxs = nil
}
================================================
FILE: api/metadata/metadata.proto
================================================
syntax = "proto3";
package kratos.api;
import "google/protobuf/descriptor.proto";
import "google/api/annotations.proto";
option go_package = "github.com/go-kratos/kratos/v2/api/proto/kratos/api;metadata";
option java_multiple_files = true;
option java_package = "com.github.kratos.api";
option objc_class_prefix = "KratosAPI";
// Metadata is api definition metadata service.
service Metadata {
// ListServices list the full name of all services.
rpc ListServices (ListServicesRequest) returns (ListServicesReply) {
option (google.api.http) = {
get: "/services",
};
}
// GetServiceDesc get the full fileDescriptorSet of service.
rpc GetServiceDesc (GetServiceDescRequest) returns (GetServiceDescReply) {
option (google.api.http) = {
get: "/services/{name}",
};
}
}
message ListServicesRequest {}
message ListServicesReply {
repeated string services = 1;
repeated string methods = 2;
}
message GetServiceDescRequest {
string name = 1;
}
message GetServiceDescReply {
google.protobuf.FileDescriptorSet file_desc_set = 1;
}
================================================
FILE: api/metadata/metadata_grpc.pb.go
================================================
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v3.19.4
// source: metadata/metadata.proto
package metadata
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
// Requires gRPC-Go v1.32.0 or later.
const _ = grpc.SupportPackageIsVersion7
// MetadataClient is the client API for Metadata service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type MetadataClient interface {
// ListServices list the full name of all services.
ListServices(ctx context.Context, in *ListServicesRequest, opts ...grpc.CallOption) (*ListServicesReply, error)
// GetServiceDesc get the full fileDescriptorSet of service.
GetServiceDesc(ctx context.Context, in *GetServiceDescRequest, opts ...grpc.CallOption) (*GetServiceDescReply, error)
}
type metadataClient struct {
cc grpc.ClientConnInterface
}
func NewMetadataClient(cc grpc.ClientConnInterface) MetadataClient {
return &metadataClient{cc}
}
func (c *metadataClient) ListServices(ctx context.Context, in *ListServicesRequest, opts ...grpc.CallOption) (*ListServicesReply, error) {
out := new(ListServicesReply)
err := c.cc.Invoke(ctx, "/kratos.api.Metadata/ListServices", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *metadataClient) GetServiceDesc(ctx context.Context, in *GetServiceDescRequest, opts ...grpc.CallOption) (*GetServiceDescReply, error) {
out := new(GetServiceDescReply)
err := c.cc.Invoke(ctx, "/kratos.api.Metadata/GetServiceDesc", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// MetadataServer is the server API for Metadata service.
// All implementations must embed UnimplementedMetadataServer
// for forward compatibility
type MetadataServer interface {
// ListServices list the full name of all services.
ListServices(context.Context, *ListServicesRequest) (*ListServicesReply, error)
// GetServiceDesc get the full fileDescriptorSet of service.
GetServiceDesc(context.Context, *GetServiceDescRequest) (*GetServiceDescReply, error)
mustEmbedUnimplementedMetadataServer()
}
// UnimplementedMetadataServer must be embedded to have forward compatible implementations.
type UnimplementedMetadataServer struct {
}
func (UnimplementedMetadataServer) ListServices(context.Context, *ListServicesRequest) (*ListServicesReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListServices not implemented")
}
func (UnimplementedMetadataServer) GetServiceDesc(context.Context, *GetServiceDescRequest) (*GetServiceDescReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetServiceDesc not implemented")
}
func (UnimplementedMetadataServer) mustEmbedUnimplementedMetadataServer() {}
// UnsafeMetadataServer may be embedded to opt out of forward compatibility for this service.
// Use of this interface is not recommended, as added methods to MetadataServer will
// result in compilation errors.
type UnsafeMetadataServer interface {
mustEmbedUnimplementedMetadataServer()
}
func RegisterMetadataServer(s grpc.ServiceRegistrar, srv MetadataServer) {
s.RegisterService(&Metadata_ServiceDesc, srv)
}
func _Metadata_ListServices_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListServicesRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MetadataServer).ListServices(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/kratos.api.Metadata/ListServices",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MetadataServer).ListServices(ctx, req.(*ListServicesRequest))
}
return interceptor(ctx, in, info, handler)
}
func _Metadata_GetServiceDesc_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(GetServiceDescRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MetadataServer).GetServiceDesc(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/kratos.api.Metadata/GetServiceDesc",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MetadataServer).GetServiceDesc(ctx, req.(*GetServiceDescRequest))
}
return interceptor(ctx, in, info, handler)
}
// Metadata_ServiceDesc is the grpc.ServiceDesc for Metadata service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
var Metadata_ServiceDesc = grpc.ServiceDesc{
ServiceName: "kratos.api.Metadata",
HandlerType: (*MetadataServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "ListServices",
Handler: _Metadata_ListServices_Handler,
},
{
MethodName: "GetServiceDesc",
Handler: _Metadata_GetServiceDesc_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "metadata/metadata.proto",
}
================================================
FILE: api/metadata/metadata_http.pb.go
================================================
// Code generated by protoc-gen-go-http. DO NOT EDIT.
// versions:
// protoc-gen-go-http v2.3.0
package metadata
import (
context "context"
http "github.com/go-kratos/kratos/v2/transport/http"
binding "github.com/go-kratos/kratos/v2/transport/http/binding"
)
// This is a compile-time assertion to ensure that this generated file
// is compatible with the kratos package it is being compiled against.
var _ = new(context.Context)
var _ = binding.EncodeURL
const _ = http.SupportPackageIsVersion1
type MetadataHTTPServer interface {
GetServiceDesc(context.Context, *GetServiceDescRequest) (*GetServiceDescReply, error)
ListServices(context.Context, *ListServicesRequest) (*ListServicesReply, error)
}
func RegisterMetadataHTTPServer(s *http.Server, srv MetadataHTTPServer) {
r := s.Route("/")
r.GET("/services", _Metadata_ListServices0_HTTP_Handler(srv))
r.GET("/services/{name}", _Metadata_GetServiceDesc0_HTTP_Handler(srv))
}
func _Metadata_ListServices0_HTTP_Handler(srv MetadataHTTPServer) func(ctx http.Context) error {
return func(ctx http.Context) error {
var in ListServicesRequest
if err := ctx.BindQuery(&in); err != nil {
return err
}
http.SetOperation(ctx, "/kratos.api.Metadata/ListServices")
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.ListServices(ctx, req.(*ListServicesRequest))
})
out, err := h(ctx, &in)
if err != nil {
return err
}
reply := out.(*ListServicesReply)
return ctx.Result(200, reply)
}
}
func _Metadata_GetServiceDesc0_HTTP_Handler(srv MetadataHTTPServer) func(ctx http.Context) error {
return func(ctx http.Context) error {
var in GetServiceDescRequest
if err := ctx.BindQuery(&in); err != nil {
return err
}
if err := ctx.BindVars(&in); err != nil {
return err
}
http.SetOperation(ctx, "/kratos.api.Metadata/GetServiceDesc")
h := ctx.Middleware(func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.GetServiceDesc(ctx, req.(*GetServiceDescRequest))
})
out, err := h(ctx, &in)
if err != nil {
return err
}
reply := out.(*GetServiceDescReply)
return ctx.Result(200, reply)
}
}
type MetadataHTTPClient interface {
GetServiceDesc(ctx context.Context, req *GetServiceDescRequest, opts ...http.CallOption) (rsp *GetServiceDescReply, err error)
ListServices(ctx context.Context, req *ListServicesRequest, opts ...http.CallOption) (rsp *ListServicesReply, err error)
}
type MetadataHTTPClientImpl struct {
cc *http.Client
}
func NewMetadataHTTPClient(client *http.Client) MetadataHTTPClient {
return &MetadataHTTPClientImpl{client}
}
func (c *MetadataHTTPClientImpl) GetServiceDesc(ctx context.Context, in *GetServiceDescRequest, opts ...http.CallOption) (*GetServiceDescReply, error) {
var out GetServiceDescReply
pattern := "/services/{name}"
path := binding.EncodeURL(pattern, in, true)
opts = append(opts, http.Operation("/kratos.api.Metadata/GetServiceDesc"))
opts = append(opts, http.PathTemplate(pattern))
err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...)
if err != nil {
return nil, err
}
return &out, err
}
func (c *MetadataHTTPClientImpl) ListServices(ctx context.Context, in *ListServicesRequest, opts ...http.CallOption) (*ListServicesReply, error) {
var out ListServicesReply
pattern := "/services"
path := binding.EncodeURL(pattern, in, true)
opts = append(opts, http.Operation("/kratos.api.Metadata/ListServices"))
opts = append(opts, http.PathTemplate(pattern))
err := c.cc.Invoke(ctx, "GET", path, nil, &out, opts...)
if err != nil {
return nil, err
}
return &out, err
}
================================================
FILE: api/metadata/server.go
================================================
package metadata
import (
"bytes"
"compress/gzip"
"context"
"errors"
"fmt"
"io"
"sort"
"sync"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protodesc"
"google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/reflect/protoregistry"
dpb "google.golang.org/protobuf/types/descriptorpb"
"github.com/go-kratos/kratos/v2/log"
)
// Server is api meta server
type Server struct {
UnimplementedMetadataServer
srv *grpc.Server
lock sync.Mutex
services map[string]*dpb.FileDescriptorSet
methods map[string][]string
}
// NewServer create server instance
func NewServer(srv *grpc.Server) *Server {
return &Server{
srv: srv,
services: make(map[string]*dpb.FileDescriptorSet),
methods: make(map[string][]string),
}
}
func (s *Server) load() error {
if len(s.services) > 0 {
return nil
}
if s.srv != nil {
for name, info := range s.srv.GetServiceInfo() {
fd, err := parseMetadata(info.Metadata)
if err != nil {
return fmt.Errorf("invalid service %s metadata err:%v", name, err)
}
protoSet, err := allDependency(fd)
if err != nil {
return err
}
s.services[name] = &dpb.FileDescriptorSet{File: protoSet}
for _, method := range info.Methods {
s.methods[name] = append(s.methods[name], method.Name)
}
}
return nil
}
var err error
protoregistry.GlobalFiles.RangeFiles(func(fd protoreflect.FileDescriptor) bool {
if fd.Services() == nil {
return true
}
for i := 0; i < fd.Services().Len(); i++ {
svc := fd.Services().Get(i)
fdp, e := fileDescriptorProto(fd.Path())
if e != nil {
err = e
return false
}
fdps, e := allDependency(fdp)
if e != nil {
if errors.Is(e, protoregistry.NotFound) {
// Skip this service if one of its dependencies is not found.
continue
}
err = e
return false
}
s.services[string(svc.FullName())] = &dpb.FileDescriptorSet{File: fdps}
if svc.Methods() == nil {
continue
}
for j := 0; j < svc.Methods().Len(); j++ {
method := svc.Methods().Get(j)
s.methods[string(svc.FullName())] = append(s.methods[string(svc.FullName())], string(method.Name()))
}
}
return true
})
return err
}
// ListServices return all services
func (s *Server) ListServices(_ context.Context, _ *ListServicesRequest) (*ListServicesReply, error) {
s.lock.Lock()
defer s.lock.Unlock()
if err := s.load(); err != nil {
return nil, err
}
reply := &ListServicesReply{
Services: make([]string, 0, len(s.services)),
Methods: make([]string, 0, len(s.methods)),
}
for name := range s.services {
reply.Services = append(reply.Services, name)
}
for name, methods := range s.methods {
for _, method := range methods {
reply.Methods = append(reply.Methods, fmt.Sprintf("/%s/%s", name, method))
}
}
sort.Strings(reply.Services)
sort.Strings(reply.Methods)
return reply, nil
}
// GetServiceDesc return service meta by name
func (s *Server) GetServiceDesc(_ context.Context, in *GetServiceDescRequest) (*GetServiceDescReply, error) {
s.lock.Lock()
defer s.lock.Unlock()
if err := s.load(); err != nil {
return nil, err
}
fds, ok := s.services[in.Name]
if !ok {
return nil, status.Errorf(codes.NotFound, "service %s not found", in.Name)
}
return &GetServiceDescReply{FileDescSet: fds}, nil
}
// parseMetadata finds the file descriptor bytes specified meta.
// For SupportPackageIsVersion4, m is the name of the proto file, we
// call proto.FileDescriptor to get the byte slice.
// For SupportPackageIsVersion3, m is a byte slice itself.
func parseMetadata(meta any) (*dpb.FileDescriptorProto, error) {
// Check if meta is the file name.
if fileNameForMeta, ok := meta.(string); ok {
return fileDescriptorProto(fileNameForMeta)
}
// Check if meta is the byte slice.
if enc, ok := meta.([]byte); ok {
return decodeFileDesc(enc)
}
return nil, fmt.Errorf("proto does not support metadata: %v", meta)
}
// decodeFileDesc does decompression and unmarshalling on the given
// file descriptor byte slice.
func decodeFileDesc(enc []byte) (*dpb.FileDescriptorProto, error) {
raw, err := decompress(enc)
if err != nil {
return nil, fmt.Errorf("failed to decompress enc: %v", err)
}
fd := new(dpb.FileDescriptorProto)
if err := proto.Unmarshal(raw, fd); err != nil {
return nil, fmt.Errorf("bad descriptor: %v", err)
}
return fd, nil
}
func allDependency(fd *dpb.FileDescriptorProto) ([]*dpb.FileDescriptorProto, error) {
var files []*dpb.FileDescriptorProto
for _, dep := range fd.Dependency {
fdDep, err := fileDescriptorProto(dep)
if err != nil {
log.Warnf("%s", err)
continue
}
temp, err := allDependency(fdDep)
if err != nil {
return nil, err
}
files = append(files, temp...)
}
files = append(files, fd)
return files, nil
}
// decompress does gzip decompression.
func decompress(b []byte) ([]byte, error) {
r, err := gzip.NewReader(bytes.NewReader(b))
if err != nil {
return nil, fmt.Errorf("bad gzipped descriptor: %v", err)
}
out, err := io.ReadAll(r)
if err != nil {
return nil, fmt.Errorf("bad gzipped descriptor: %v", err)
}
return out, nil
}
func fileDescriptorProto(path string) (*dpb.FileDescriptorProto, error) {
fd, err := protoregistry.GlobalFiles.FindFileByPath(path)
if err != nil {
return nil, fmt.Errorf("find proto by path failed, path: %s, err: %s", path, err)
}
fdpb := protodesc.ToFileDescriptorProto(fd)
return fdpb, nil
}
================================================
FILE: app.go
================================================
package kratos
import (
"context"
"errors"
"os"
"os/signal"
"sync"
"syscall"
"time"
"github.com/google/uuid"
"golang.org/x/sync/errgroup"
"github.com/go-kratos/kratos/v2/log"
"github.com/go-kratos/kratos/v2/registry"
"github.com/go-kratos/kratos/v2/transport"
)
// AppInfo is application context value.
type AppInfo interface {
ID() string
Name() string
Version() string
Metadata() map[string]string
Endpoint() []string
}
// App is an application components lifecycle manager.
type App struct {
opts options
ctx context.Context
cancel context.CancelFunc
mu sync.Mutex
instance *registry.ServiceInstance
}
// New create an application lifecycle manager.
func New(opts ...Option) *App {
o := options{
ctx: context.Background(),
sigs: []os.Signal{syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGINT},
registrarTimeout: 10 * time.Second,
}
if id, err := uuid.NewUUID(); err == nil {
o.id = id.String()
}
for _, opt := range opts {
opt(&o)
}
if o.logger != nil {
log.SetLogger(o.logger)
}
ctx, cancel := context.WithCancel(o.ctx)
return &App{
ctx: ctx,
cancel: cancel,
opts: o,
}
}
// ID returns app instance id.
func (a *App) ID() string { return a.opts.id }
// Name returns service name.
func (a *App) Name() string { return a.opts.name }
// Version returns app version.
func (a *App) Version() string { return a.opts.version }
// Metadata returns service metadata.
func (a *App) Metadata() map[string]string { return a.opts.metadata }
// Endpoint returns endpoints.
func (a *App) Endpoint() []string {
if a.instance != nil {
return a.instance.Endpoints
}
return nil
}
// Run executes all OnStart hooks registered with the application's Lifecycle.
func (a *App) Run() error {
instance, err := a.buildInstance()
if err != nil {
return err
}
a.mu.Lock()
a.instance = instance
a.mu.Unlock()
sctx := NewContext(a.ctx, a)
eg, ctx := errgroup.WithContext(sctx)
wg := sync.WaitGroup{}
for _, fn := range a.opts.beforeStart {
if err = fn(sctx); err != nil {
return err
}
}
octx := NewContext(a.opts.ctx, a)
for _, srv := range a.opts.servers {
server := srv
eg.Go(func() error {
<-ctx.Done() // wait for stop signal
stopCtx := context.WithoutCancel(octx)
if a.opts.stopTimeout > 0 {
var cancel context.CancelFunc
stopCtx, cancel = context.WithTimeout(stopCtx, a.opts.stopTimeout)
defer cancel()
}
return server.Stop(stopCtx)
})
wg.Add(1)
eg.Go(func() error {
wg.Done() // here is to ensure server start has begun running before register, so defer is not needed
return server.Start(octx)
})
}
wg.Wait()
if a.opts.registrar != nil {
rctx, rcancel := context.WithTimeout(ctx, a.opts.registrarTimeout)
defer rcancel()
if err = a.opts.registrar.Register(rctx, instance); err != nil {
return err
}
}
for _, fn := range a.opts.afterStart {
if err = fn(sctx); err != nil {
return err
}
}
c := make(chan os.Signal, 1)
signal.Notify(c, a.opts.sigs...)
eg.Go(func() error {
select {
case <-ctx.Done():
return nil
case <-c:
return a.Stop()
}
})
if err = eg.Wait(); err != nil && !errors.Is(err, context.Canceled) {
return err
}
err = nil
for _, fn := range a.opts.afterStop {
err = fn(sctx)
}
return err
}
// Stop gracefully stops the application.
func (a *App) Stop() (err error) {
sctx := NewContext(a.ctx, a)
for _, fn := range a.opts.beforeStop {
err = fn(sctx)
}
a.mu.Lock()
instance := a.instance
a.mu.Unlock()
if a.opts.registrar != nil && instance != nil {
ctx, cancel := context.WithTimeout(NewContext(a.ctx, a), a.opts.registrarTimeout)
defer cancel()
if err = a.opts.registrar.Deregister(ctx, instance); err != nil {
return err
}
}
if a.cancel != nil {
a.cancel()
}
return err
}
func (a *App) buildInstance() (*registry.ServiceInstance, error) {
endpoints := make([]string, 0, len(a.opts.endpoints))
for _, e := range a.opts.endpoints {
endpoints = append(endpoints, e.String())
}
if len(endpoints) == 0 {
for _, srv := range a.opts.servers {
if r, ok := srv.(transport.Endpointer); ok {
e, err := r.Endpoint()
if err != nil {
return nil, err
}
endpoints = append(endpoints, e.String())
}
}
}
return ®istry.ServiceInstance{
ID: a.opts.id,
Name: a.opts.name,
Version: a.opts.version,
Metadata: a.opts.metadata,
Endpoints: endpoints,
}, nil
}
type appKey struct{}
// NewContext returns a new Context that carries value.
func NewContext(ctx context.Context, s AppInfo) context.Context {
return context.WithValue(ctx, appKey{}, s)
}
// FromContext returns the Transport value stored in ctx, if any.
func FromContext(ctx context.Context) (s AppInfo, ok bool) {
s, ok = ctx.Value(appKey{}).(AppInfo)
return
}
================================================
FILE: app_test.go
================================================
package kratos
import (
"context"
"errors"
"net/url"
"reflect"
"sync"
"testing"
"time"
"github.com/go-kratos/kratos/v2/registry"
"github.com/go-kratos/kratos/v2/transport/grpc"
"github.com/go-kratos/kratos/v2/transport/http"
)
type mockRegistry struct {
lk sync.Mutex
service map[string]*registry.ServiceInstance
}
func (r *mockRegistry) Register(_ context.Context, service *registry.ServiceInstance) error {
if service == nil || service.ID == "" {
return errors.New("no service id")
}
r.lk.Lock()
defer r.lk.Unlock()
r.service[service.ID] = service
return nil
}
// Deregister the registration.
func (r *mockRegistry) Deregister(_ context.Context, service *registry.ServiceInstance) error {
r.lk.Lock()
defer r.lk.Unlock()
if r.service[service.ID] == nil {
return errors.New("deregister service not found")
}
delete(r.service, service.ID)
return nil
}
func TestApp(t *testing.T) {
hs := http.NewServer()
gs := grpc.NewServer()
app := New(
Name("kratos"),
Version("v1.0.0"),
Server(hs, gs),
BeforeStart(func(_ context.Context) error {
t.Log("BeforeStart...")
return nil
}),
BeforeStop(func(_ context.Context) error {
t.Log("BeforeStop...")
return nil
}),
AfterStart(func(_ context.Context) error {
t.Log("AfterStart...")
return nil
}),
AfterStop(func(_ context.Context) error {
t.Log("AfterStop...")
return nil
}),
Registrar(&mockRegistry{service: make(map[string]*registry.ServiceInstance)}),
)
time.AfterFunc(time.Second, func() {
_ = app.Stop()
})
if err := app.Run(); err != nil {
t.Fatal(err)
}
}
func TestApp_ID(t *testing.T) {
v := "123"
o := New(ID(v))
if !reflect.DeepEqual(v, o.ID()) {
t.Fatalf("o.ID():%s is not equal to v:%s", o.ID(), v)
}
}
func TestApp_Name(t *testing.T) {
v := "123"
o := New(Name(v))
if !reflect.DeepEqual(v, o.Name()) {
t.Fatalf("o.Name():%s is not equal to v:%s", o.Name(), v)
}
}
func TestApp_Version(t *testing.T) {
v := "123"
o := New(Version(v))
if !reflect.DeepEqual(v, o.Version()) {
t.Fatalf("o.Version():%s is not equal to v:%s", o.Version(), v)
}
}
func TestApp_Metadata(t *testing.T) {
v := map[string]string{
"a": "1",
"b": "2",
}
o := New(Metadata(v))
if !reflect.DeepEqual(v, o.Metadata()) {
t.Fatalf("o.Metadata():%s is not equal to v:%s", o.Metadata(), v)
}
}
func TestApp_Endpoint(t *testing.T) {
v := []string{"https://go-kratos.dev", "localhost"}
var endpoints []*url.URL
for _, urlStr := range v {
if endpoint, err := url.Parse(urlStr); err != nil {
t.Errorf("invalid endpoint:%v", urlStr)
} else {
endpoints = append(endpoints, endpoint)
}
}
o := New(Endpoint(endpoints...))
if instance, err := o.buildInstance(); err != nil {
t.Error("build instance failed")
} else {
o.instance = instance
}
if !reflect.DeepEqual(o.Endpoint(), v) {
t.Errorf("Endpoint() = %v, want %v", o.Endpoint(), v)
}
}
func TestApp_buildInstance(t *testing.T) {
want := struct {
id string
name string
version string
metadata map[string]string
endpoints []string
}{
id: "1",
name: "kratos",
version: "v1.0.0",
metadata: map[string]string{
"a": "1",
"b": "2",
},
endpoints: []string{"https://go-kratos.dev", "localhost"},
}
var endpoints []*url.URL
for _, urlStr := range want.endpoints {
if endpoint, err := url.Parse(urlStr); err != nil {
t.Errorf("invalid endpoint:%v", urlStr)
} else {
endpoints = append(endpoints, endpoint)
}
}
app := New(
ID(want.id),
Name(want.name),
Version(want.version),
Metadata(want.metadata),
Endpoint(endpoints...),
)
if got, err := app.buildInstance(); err != nil {
t.Error("build got failed")
} else {
if got.ID != want.id {
t.Errorf("ID() = %v, want %v", got.ID, want.id)
}
if got.Name != want.name {
t.Errorf("Name() = %v, want %v", got.Name, want.name)
}
if got.Version != want.version {
t.Errorf("Version() = %v, want %v", got.Version, want.version)
}
if !reflect.DeepEqual(got.Endpoints, want.endpoints) {
t.Errorf("Endpoint() = %v, want %v", got.Endpoints, want.endpoints)
}
if !reflect.DeepEqual(got.Metadata, want.metadata) {
t.Errorf("Metadata() = %v, want %v", got.Metadata, want.metadata)
}
}
}
func TestApp_Context(t *testing.T) {
type fields struct {
id string
version string
name string
instance *registry.ServiceInstance
metadata map[string]string
want struct {
id string
version string
name string
endpoint []string
metadata map[string]string
}
}
tests := []fields{
{
id: "1",
name: "kratos-v1",
instance: ®istry.ServiceInstance{Endpoints: []string{"https://go-kratos.dev", "localhost"}},
metadata: map[string]string{},
version: "v1",
want: struct {
id string
version string
name string
endpoint []string
metadata map[string]string
}{
id: "1", version: "v1", name: "kratos-v1", endpoint: []string{"https://go-kratos.dev", "localhost"},
metadata: map[string]string{},
},
},
{
id: "2",
name: "kratos-v2",
instance: ®istry.ServiceInstance{Endpoints: []string{"test"}},
metadata: map[string]string{"kratos": "https://github.com/go-kratos/kratos"},
version: "v2",
want: struct {
id string
version string
name string
endpoint []string
metadata map[string]string
}{
id: "2", version: "v2", name: "kratos-v2", endpoint: []string{"test"},
metadata: map[string]string{"kratos": "https://github.com/go-kratos/kratos"},
},
},
{
id: "3",
name: "kratos-v3",
instance: nil,
metadata: make(map[string]string),
version: "v3",
want: struct {
id string
version string
name string
endpoint []string
metadata map[string]string
}{
id: "3", version: "v3", name: "kratos-v3", endpoint: nil,
metadata: map[string]string{},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
a := &App{
opts: options{id: tt.id, name: tt.name, metadata: tt.metadata, version: tt.version},
ctx: context.Background(),
cancel: nil,
instance: tt.instance,
}
ctx := NewContext(context.Background(), a)
if got, ok := FromContext(ctx); ok {
if got.ID() != tt.want.id {
t.Errorf("ID() = %v, want %v", got.ID(), tt.want.id)
}
if got.Name() != tt.want.name {
t.Errorf("Name() = %v, want %v", got.Name(), tt.want.name)
}
if got.Version() != tt.want.version {
t.Errorf("Version() = %v, want %v", got.Version(), tt.want.version)
}
if !reflect.DeepEqual(got.Endpoint(), tt.want.endpoint) {
t.Errorf("Endpoint() = %v, want %v", got.Endpoint(), tt.want.endpoint)
}
if !reflect.DeepEqual(got.Metadata(), tt.want.metadata) {
t.Errorf("Metadata() = %v, want %v", got.Metadata(), tt.want.metadata)
}
} else {
t.Errorf("ok() = %v, want %v", ok, true)
}
})
}
}
func TestApp_ContextCanceled(t *testing.T) {
ctx, stop := context.WithCancel(context.Background())
stopFn := func(ctx context.Context) error {
select {
case <-ctx.Done():
t.Fatal("context should not be done yet")
default:
}
return nil
}
app := New(Context(ctx), Server(&mockServer{stopFn: stopFn}), StopTimeout(time.Hour))
time.AfterFunc(time.Millisecond*10, stop)
_ = app.Run()
}
================================================
FILE: cmd/kratos/go.mod
================================================
module github.com/go-kratos/kratos/cmd/kratos/v2
go 1.23.0
toolchain go1.24.6
require (
github.com/AlecAivazis/survey/v2 v2.3.7
github.com/charmbracelet/huh v0.8.0
github.com/emicklei/proto v1.10.0
github.com/fatih/color v1.13.0
github.com/spf13/cobra v1.4.0
golang.org/x/mod v0.17.0
golang.org/x/text v0.23.0
)
require (
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/catppuccin/go v0.3.0 // indirect
github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7 // indirect
github.com/charmbracelet/bubbletea v1.3.6 // indirect
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc // indirect
github.com/charmbracelet/lipgloss v1.1.0 // indirect
github.com/charmbracelet/x/ansi v0.9.3 // indirect
github.com/charmbracelet/x/cellbuf v0.0.13 // indirect
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 // indirect
github.com/charmbracelet/x/term v0.2.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.16 // indirect
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.16.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.7.0 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/sync v0.15.0 // indirect
golang.org/x/sys v0.33.0 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
gopkg.in/yaml.v3 v3.0.0 // indirect
)
================================================
FILE: cmd/kratos/go.sum
================================================
github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ=
github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo=
github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ=
github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE=
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s=
github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w=
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
github.com/aymanbagabas/go-osc52/v2 v2.0.1/go.mod h1:uYgXzlJ7ZpABp8OJ+exZzJJhRNQ2ASbcXHWsFqH8hp8=
github.com/aymanbagabas/go-udiff v0.3.1 h1:LV+qyBQ2pqe0u42ZsUEtPiCaUoqgA9gYRDs3vj1nolY=
github.com/aymanbagabas/go-udiff v0.3.1/go.mod h1:G0fsKmG+P6ylD0r6N/KgQD/nWzgfnl8ZBcNLgcbrw8E=
github.com/catppuccin/go v0.3.0 h1:d+0/YicIq+hSTo5oPuRi5kOpqkVA5tAsU6dNhvRu+aY=
github.com/catppuccin/go v0.3.0/go.mod h1:8IHJuMGaUUjQM82qBrGNBv7LFq6JI3NnQCF6MOlZjpc=
github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7 h1:JFgG/xnwFfbezlUnFMJy0nusZvytYysV4SCS2cYbvws=
github.com/charmbracelet/bubbles v0.21.1-0.20250623103423-23b8fd6302d7/go.mod h1:ISC1gtLcVilLOf23wvTfoQuYbW2q0JevFxPfUzZ9Ybw=
github.com/charmbracelet/bubbletea v1.3.6 h1:VkHIxPJQeDt0aFJIsVxw8BQdh/F/L2KKZGsK6et5taU=
github.com/charmbracelet/bubbletea v1.3.6/go.mod h1:oQD9VCRQFF8KplacJLo28/jofOI2ToOfGYeFgBBxHOc=
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc h1:4pZI35227imm7yK2bGPcfpFEmuY1gc2YSTShr4iJBfs=
github.com/charmbracelet/colorprofile v0.2.3-0.20250311203215-f60798e515dc/go.mod h1:X4/0JoqgTIPSFcRA/P6INZzIuyqdFY5rm8tb41s9okk=
github.com/charmbracelet/huh v0.8.0 h1:Xz/Pm2h64cXQZn/Jvele4J3r7DDiqFCNIVteYukxDvY=
github.com/charmbracelet/huh v0.8.0/go.mod h1:5YVc+SlZ1IhQALxRPpkGwwEKftN/+OlJlnJYlDRFqN4=
github.com/charmbracelet/lipgloss v1.1.0 h1:vYXsiLHVkK7fp74RkV7b2kq9+zDLoEU4MZoFqR/noCY=
github.com/charmbracelet/lipgloss v1.1.0/go.mod h1:/6Q8FR2o+kj8rz4Dq0zQc3vYf7X+B0binUUBwA0aL30=
github.com/charmbracelet/x/ansi v0.9.3 h1:BXt5DHS/MKF+LjuK4huWrC6NCvHtexww7dMayh6GXd0=
github.com/charmbracelet/x/ansi v0.9.3/go.mod h1:3RQDQ6lDnROptfpWuUVIUG64bD2g2BgntdxH0Ya5TeE=
github.com/charmbracelet/x/cellbuf v0.0.13 h1:/KBBKHuVRbq1lYx5BzEHBAFBP8VcQzJejZ/IA3iR28k=
github.com/charmbracelet/x/cellbuf v0.0.13/go.mod h1:xe0nKWGd3eJgtqZRaN9RjMtK7xUYchjzPr7q6kcvCCs=
github.com/charmbracelet/x/conpty v0.1.0 h1:4zc8KaIcbiL4mghEON8D72agYtSeIgq8FSThSPQIb+U=
github.com/charmbracelet/x/conpty v0.1.0/go.mod h1:rMFsDJoDwVmiYM10aD4bH2XiRgwI7NYJtQgl5yskjEQ=
github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86 h1:JSt3B+U9iqk37QUU2Rvb6DSBYRLtWqFqfxf8l5hOZUA=
github.com/charmbracelet/x/errors v0.0.0-20240508181413-e8d8b6e2de86/go.mod h1:2P0UgXMEa6TsToMSuFqKFQR+fZTO9CNGUNokkPatT/0=
github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91 h1:payRxjMjKgx2PaCWLZ4p3ro9y97+TVLZNaRZgJwSVDQ=
github.com/charmbracelet/x/exp/golden v0.0.0-20241011142426-46044092ad91/go.mod h1:wDlXFlCrmJ8J+swcL/MnGUuYnqgQdW9rhSD61oNMb6U=
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 h1:qko3AQ4gK1MTS/de7F5hPGx6/k1u0w4TeYmBFwzYVP4=
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0/go.mod h1:pBhA0ybfXv6hDjQUZ7hk1lVxBiUbupdw5R31yPUViVQ=
github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
github.com/charmbracelet/x/termios v0.1.1 h1:o3Q2bT8eqzGnGPOYheoYS8eEleT5ZVNYNy8JawjaNZY=
github.com/charmbracelet/x/termios v0.1.1/go.mod h1:rB7fnv1TgOPOyyKRJ9o+AsTU/vK5WHJ2ivHeut/Pcwo=
github.com/charmbracelet/x/xpty v0.1.2 h1:Pqmu4TEJ8KeA9uSkISKMU3f+C1F6OGBn8ABuGlqCbtI=
github.com/charmbracelet/x/xpty v0.1.2/go.mod h1:XK2Z0id5rtLWcpeNiMYBccNNBrP2IJnzHI0Lq13Xzq4=
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s=
github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/emicklei/proto v1.10.0 h1:pDGyFRVV5RvV+nkBK9iy3q67FBy9Xa7vwrOTE+g5aGw=
github.com/emicklei/proto v1.10.0/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec h1:qv2VnGeEQHchGaZ/u7lxST/RaJw+cv273q79D81Xbog=
github.com/hinshun/vt10x v0.0.0-20220119200601-820417d04eec/go.mod h1:Q48J4R4DvxnHolD5P8pOtXigYlRuPLGl6moFx3ulM68=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40=
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4=
github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE=
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 h1:ZK8zHtRHOkbHy6Mmr5D264iyp3TiX5OmNcI5cIARiQI=
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6/go.mod h1:CJlz5H+gyd6CUWT45Oy4q24RdLyn7Md9Vj2/ldJBSIo=
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.4.0 h1:y+wJpx64xcgO1V+RcnwW0LEHxTKRi2ZDPSBjWnrg88Q=
github.com/spf13/cobra v1.4.0/go.mod h1:Wo4iy3BUC+X2Fybo0PDqwJIv3dNRiZLHQymsfxlB84g=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=
golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA=
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
================================================
FILE: cmd/kratos/internal/base/install.go
================================================
package base
import (
"fmt"
"os"
"os/exec"
"strings"
)
// GoInstall go get path.
func GoInstall(path ...string) error {
for _, p := range path {
if !strings.Contains(p, "@") {
p += "@latest"
}
fmt.Printf("go install %s\n", p)
cmd := exec.Command("go", "install", p)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
return err
}
}
return nil
}
================================================
FILE: cmd/kratos/internal/base/mod.go
================================================
package base
import (
"bufio"
"bytes"
"os"
"os/exec"
"path/filepath"
"strings"
"golang.org/x/mod/modfile"
)
// ModulePath returns go module path.
func ModulePath(filename string) (string, error) {
modBytes, err := os.ReadFile(filename)
if err != nil {
return "", err
}
return modfile.ModulePath(modBytes), nil
}
// ModuleVersion returns module version.
func ModuleVersion(path string) (string, error) {
stdout := &bytes.Buffer{}
fd := exec.Command("go", "mod", "graph")
fd.Stdout = stdout
fd.Stderr = stdout
if err := fd.Run(); err != nil {
return "", err
}
rd := bufio.NewReader(stdout)
for {
line, _, err := rd.ReadLine()
if err != nil {
return "", err
}
str := string(line)
i := strings.Index(str, "@")
if strings.Contains(str, path+"@") && i != -1 {
return path + str[i:], nil
}
}
}
// KratosMod returns kratos mod.
func KratosMod() string {
// go 1.15+ read from env GOMODCACHE
cacheOut, _ := exec.Command("go", "env", "GOMODCACHE").Output()
cachePath := strings.Trim(string(cacheOut), "\n")
pathOut, _ := exec.Command("go", "env", "GOPATH").Output()
gopath := strings.Trim(string(pathOut), "\n")
if cachePath == "" {
cachePath = filepath.Join(gopath, "pkg", "mod")
}
if path, err := ModuleVersion("github.com/go-kratos/kratos/v2"); err == nil {
// $GOPATH/pkg/mod/github.com/go-kratos/kratos@v2
return filepath.Join(cachePath, path)
}
// $GOPATH/src/github.com/go-kratos/kratos
return filepath.Join(gopath, "src", "github.com", "go-kratos", "kratos")
}
================================================
FILE: cmd/kratos/internal/base/mod_test.go
================================================
package base
import (
"os"
"testing"
)
func TestModuleVersion(t *testing.T) {
v, err := ModuleVersion("golang.org/x/mod")
if err != nil {
t.Fatal(err)
}
t.Log(v)
}
func TestModulePath(t *testing.T) {
if err := os.Mkdir("/tmp/test_mod", os.ModePerm); err != nil {
t.Fatal(err)
}
f, err := os.Create("/tmp/test_mod/go.mod")
if err != nil {
t.Fatal(err)
}
mod := `module github.com/go-kratos/kratos/v2
go 1.21`
_, err = f.WriteString(mod)
if err != nil {
t.Fatal(err)
}
p, err := ModulePath("/tmp/test_mod/go.mod")
if err != nil {
t.Fatal(err)
}
if p != "github.com/go-kratos/kratos/v2" {
t.Fatalf("want: %s, got: %s", "github.com/go-kratos/kratos/v2", p)
}
t.Cleanup(func() { os.RemoveAll("/tmp/test_mod") })
}
================================================
FILE: cmd/kratos/internal/base/path.go
================================================
package base
import (
"bytes"
"fmt"
"log"
"os"
"path/filepath"
"strings"
"github.com/fatih/color"
)
func kratosHome() string {
dir, err := os.UserHomeDir()
if err != nil {
log.Fatal(err)
}
home := filepath.Join(dir, ".kratos")
if _, err := os.Stat(home); os.IsNotExist(err) {
if err := os.MkdirAll(home, 0o700); err != nil {
log.Fatal(err)
}
}
return home
}
func kratosHomeWithDir(dir string) string {
home := filepath.Join(kratosHome(), dir)
if _, err := os.Stat(home); os.IsNotExist(err) {
if err := os.MkdirAll(home, 0o700); err != nil {
log.Fatal(err)
}
}
return home
}
func copyFile(src, dst string, replaces []string) error {
srcinfo, err := os.Stat(src)
if err != nil {
return err
}
buf, err := os.ReadFile(src)
if err != nil {
return err
}
var old string
for i, next := range replaces {
if i%2 == 0 {
old = next
continue
}
buf = bytes.ReplaceAll(buf, []byte(old), []byte(next))
}
return os.WriteFile(dst, buf, srcinfo.Mode())
}
func copyDir(src, dst string, replaces, ignores []string) error {
srcinfo, err := os.Stat(src)
if err != nil {
return err
}
err = os.MkdirAll(dst, srcinfo.Mode())
if err != nil {
return err
}
fds, err := os.ReadDir(src)
if err != nil {
return err
}
for _, fd := range fds {
if hasSets(fd.Name(), ignores) {
continue
}
srcfp := filepath.Join(src, fd.Name())
dstfp := filepath.Join(dst, fd.Name())
var e error
if fd.IsDir() {
e = copyDir(srcfp, dstfp, replaces, ignores)
} else {
e = copyFile(srcfp, dstfp, replaces)
}
if e != nil {
return e
}
}
return nil
}
func hasSets(name string, sets []string) bool {
for _, ig := range sets {
if ig == name {
return true
}
}
return false
}
func Tree(path string, dir string) {
_ = filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
if err == nil && info != nil && !info.IsDir() {
fmt.Printf("%s %s (%v bytes)\n", color.GreenString("CREATED"), strings.ReplaceAll(path, dir+"/", ""), info.Size())
}
return nil
})
}
================================================
FILE: cmd/kratos/internal/base/repo.go
================================================
package base
import (
"context"
"fmt"
"net"
"os"
"os/exec"
"path"
"path/filepath"
"strings"
)
var unExpandVarPath = []string{"~", ".", ".."}
// Repo is git repository manager.
type Repo struct {
url string
home string
branch string
}
func repoDir(url string) string {
vcsURL, err := ParseVCSUrl(url)
if err != nil {
return url
}
// check host contains port
host, _, err := net.SplitHostPort(vcsURL.Host)
if err != nil {
host = vcsURL.Host
}
for _, p := range unExpandVarPath {
host = strings.TrimLeft(host, p)
}
dir := path.Base(path.Dir(vcsURL.Path))
url = fmt.Sprintf("%s/%s", host, dir)
return url
}
// NewRepo new a repository manager.
func NewRepo(url string, branch string) *Repo {
return &Repo{
url: url,
home: kratosHomeWithDir("repo/" + repoDir(url)),
branch: branch,
}
}
// Path returns the repository cache path.
func (r *Repo) Path() string {
start := strings.LastIndex(r.url, "/")
end := strings.LastIndex(r.url, ".git")
if end == -1 {
end = len(r.url)
}
var branch string
if r.branch == "" {
branch = "@main"
} else {
branch = "@" + r.branch
}
return path.Join(r.home, r.url[start+1:end]+branch)
}
// Pull fetch the repository from remote url.
func (r *Repo) Pull(ctx context.Context) error {
cmd := exec.CommandContext(ctx, "git", "symbolic-ref", "HEAD")
cmd.Dir = r.Path()
_, err := cmd.CombinedOutput()
if err != nil {
return err
}
cmd = exec.CommandContext(ctx, "git", "pull")
cmd.Dir = r.Path()
out, err := cmd.CombinedOutput()
fmt.Println(string(out))
if err != nil {
return err
}
return err
}
// Clone clones the repository to cache path.
func (r *Repo) Clone(ctx context.Context) error {
if _, err := os.Stat(r.Path()); !os.IsNotExist(err) {
return r.Pull(ctx)
}
var cmd *exec.Cmd
if r.branch == "" {
cmd = exec.CommandContext(ctx, "git", "clone", r.url, r.Path())
} else {
cmd = exec.CommandContext(ctx, "git", "clone", "-b", r.branch, r.url, r.Path())
}
out, err := cmd.CombinedOutput()
fmt.Println(string(out))
if err != nil {
return err
}
return nil
}
// CopyTo copies the repository to project path.
func (r *Repo) CopyTo(ctx context.Context, to string, modPath string, ignores []string) error {
if err := r.Clone(ctx); err != nil {
return err
}
mod, err := ModulePath(filepath.Join(r.Path(), "go.mod"))
if err != nil {
return err
}
return copyDir(r.Path(), to, []string{mod, modPath}, ignores)
}
// CopyToV2 copies the repository to project path
func (r *Repo) CopyToV2(ctx context.Context, to string, modPath string, ignores, replaces []string) error {
if err := r.Clone(ctx); err != nil {
return err
}
mod, err := ModulePath(filepath.Join(r.Path(), "go.mod"))
if err != nil {
return err
}
replaces = append([]string{mod, modPath}, replaces...)
return copyDir(r.Path(), to, replaces, ignores)
}
================================================
FILE: cmd/kratos/internal/base/repo_test.go
================================================
package base
import (
"context"
"os"
"testing"
)
func TestRepo(t *testing.T) {
urls := []string{
// ssh://[user@]host.xz[:port]/path/to/repo.git/
"ssh://git@github.com:7875/go-kratos/kratos.git",
// git://host.xz[:port]/path/to/repo.git/
"git://github.com:7875/go-kratos/kratos.git",
// http[s]://host.xz[:port]/path/to/repo.git/
"https://github.com:7875/go-kratos/kratos.git",
// ftp[s]://host.xz[:port]/path/to/repo.git/
"ftps://github.com:7875/go-kratos/kratos.git",
//[user@]host.xz:path/to/repo.git/
"git@github.com:go-kratos/kratos.git",
// ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/
"ssh://git@github.com:7875/go-kratos/kratos.git",
// git://host.xz[:port]/~[user]/path/to/repo.git/
"git://github.com:7875/go-kratos/kratos.git",
//[user@]host.xz:/~[user]/path/to/repo.git/
"git@github.com:go-kratos/kratos.git",
///path/to/repo.git/
"//github.com/go-kratos/kratos.git",
// file:///path/to/repo.git/
"file://./github.com/go-kratos/kratos.git",
}
for _, url := range urls {
dir := repoDir(url)
if dir != "github.com/go-kratos" && dir != "/go-kratos" {
t.Fatal(url, "repoDir test failed", dir)
}
}
}
func TestRepoClone(t *testing.T) {
r := NewRepo("https://github.com/go-kratos/service-layout.git", "")
if err := r.Clone(context.Background()); err != nil {
t.Fatal(err)
}
if err := r.CopyTo(context.Background(), "/tmp/test_repo", "github.com/go-kratos/kratos-layout", nil); err != nil {
t.Fatal(err)
}
t.Cleanup(func() {
os.RemoveAll("/tmp/test_repo")
})
}
================================================
FILE: cmd/kratos/internal/base/vcs_url.go
================================================
package base
import (
"errors"
"net/url"
"regexp"
"strings"
)
var (
scpSyntaxRe = regexp.MustCompile(`^(\w+)@([\w.-]+):(.*)$`)
scheme = []string{"git", "https", "http", "git+ssh", "ssh", "file", "ftp", "ftps"}
)
// ParseVCSUrl ref https://github.com/golang/go/blob/master/src/cmd/go/internal/vcs/vcs.go
// see https://go-review.googlesource.com/c/go/+/12226/
// git url define https://git-scm.com/docs/git-clone#_git_urls
func ParseVCSUrl(repo string) (*url.URL, error) {
var (
repoURL *url.URL
err error
)
if m := scpSyntaxRe.FindStringSubmatch(repo); m != nil {
// Match SCP-like syntax and convert it to a URL.
// Eg, "git@github.com:user/repo" becomes
// "ssh://git@github.com/user/repo".
repoURL = &url.URL{
Scheme: "ssh",
User: url.User(m[1]),
Host: m[2],
Path: m[3],
}
} else {
if !strings.Contains(repo, "//") {
repo = "//" + repo
}
if strings.HasPrefix(repo, "//git@") {
repo = "ssh:" + repo
} else if strings.HasPrefix(repo, "//") {
repo = "https:" + repo
}
repoURL, err = url.Parse(repo)
if err != nil {
return nil, err
}
}
// Iterate over insecure schemes too, because this function simply
// reports the state of the repo. If we can't see insecure schemes then
// we can't report the actual repo URL.
for _, s := range scheme {
if repoURL.Scheme == s {
return repoURL, nil
}
}
return nil, errors.New("unable to parse repo url")
}
================================================
FILE: cmd/kratos/internal/base/vcs_url_test.go
================================================
package base
import (
"net"
"strings"
"testing"
)
func TestParseVCSUrl(t *testing.T) {
repos := []string{
// ssh://[user@]host.xz[:port]/path/to/repo.git/
"ssh://git@github.com:7875/go-kratos/kratos.git",
// git://host.xz[:port]/path/to/repo.git/
"git://github.com:7875/go-kratos/kratos.git",
// http[s]://host.xz[:port]/path/to/repo.git/
"https://github.com:7875/go-kratos/kratos.git",
// ftp[s]://host.xz[:port]/path/to/repo.git/
"ftps://github.com:7875/go-kratos/kratos.git",
//[user@]host.xz:path/to/repo.git/
"git@github.com:go-kratos/kratos.git",
// ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/
"ssh://git@github.com:7875/go-kratos/kratos.git",
// git://host.xz[:port]/~[user]/path/to/repo.git/
"git://github.com:7875/go-kratos/kratos.git",
//[user@]host.xz:/~[user]/path/to/repo.git/
"git@github.com:go-kratos/kratos.git",
///path/to/repo.git/
"~/go-kratos/kratos.git",
// file:///path/to/repo.git/
"file://~/go-kratos/kratos.git",
}
for _, repo := range repos {
url, err := ParseVCSUrl(repo)
if err != nil {
t.Fatal(repo, err)
}
urlPath := strings.TrimLeft(url.Path, "/")
if urlPath != "go-kratos/kratos.git" {
t.Fatal(repo, "parse url failed", urlPath)
}
}
}
func TestParseSsh(t *testing.T) {
repo := "ssh://git@github.com:7875/go-kratos/kratos.git"
url, err := ParseVCSUrl(repo)
if err != nil {
t.Fatal(err)
}
host, _, err := net.SplitHostPort(url.Host)
if err != nil {
host = url.Host
}
t.Log(host, url.Path)
}
================================================
FILE: cmd/kratos/internal/change/change.go
================================================
package change
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
// CmdChange is kratos change log tool
var CmdChange = &cobra.Command{
Use: "changelog",
Short: "Get a kratos change log",
Long: "Get a kratos release or commits info. Example: kratos changelog dev or kratos changelog {version}",
Run: run,
}
var (
token string
repoURL string
)
func init() {
if repoURL = os.Getenv("KRATOS_REPO"); repoURL == "" {
repoURL = "https://github.com/go-kratos/kratos.git"
}
CmdChange.Flags().StringVarP(&repoURL, "repo-url", "r", repoURL, "github repo")
token = os.Getenv("GITHUB_TOKEN")
}
func run(_ *cobra.Command, args []string) {
owner, repo := ParseGithubURL(repoURL)
api := GithubAPI{Owner: owner, Repo: repo, Token: token}
version := "latest"
if len(args) > 0 {
version = args[0]
}
if version == "dev" {
info := api.GetCommitsInfo()
fmt.Print(ParseCommitsInfo(info))
return
}
info := api.GetReleaseInfo(version)
fmt.Print(ParseReleaseInfo(info))
}
================================================
FILE: cmd/kratos/internal/change/get.go
================================================
package change
import (
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"os"
"regexp"
"strings"
"time"
)
type ReleaseInfo struct {
Author struct {
Login string `json:"login"`
} `json:"author"`
PublishedAt string `json:"published_at"`
Body string `json:"body"`
HTMLURL string `json:"html_url"`
}
type CommitInfo struct {
Commit struct {
Message string `json:"message"`
} `json:"commit"`
}
type ErrorInfo struct {
Message string
}
type GithubAPI struct {
Owner string
Repo string
Token string
}
// GetReleaseInfo for getting kratos release info.
func (g *GithubAPI) GetReleaseInfo(version string) ReleaseInfo {
api := fmt.Sprintf("https://api.github.com/repos/%s/%s/releases/latest", g.Owner, g.Repo)
if version != "latest" {
api = fmt.Sprintf("https://api.github.com/repos/%s/%s/releases/tags/%s", g.Owner, g.Repo, version)
}
resp, code := requestGithubAPI(api, http.MethodGet, nil, g.Token)
if code != http.StatusOK {
printGithubErrorInfo(resp)
}
releaseInfo := ReleaseInfo{}
err := json.Unmarshal(resp, &releaseInfo)
if err != nil {
fatal(err)
}
return releaseInfo
}
// GetCommitsInfo for getting kratos commits info.
func (g *GithubAPI) GetCommitsInfo() []CommitInfo {
info := g.GetReleaseInfo("latest")
page := 1
prePage := 100
var list []CommitInfo
for {
url := fmt.Sprintf("https://api.github.com/repos/%s/%s/commits?pre_page=%d&page=%d&since=%s", g.Owner, g.Repo, prePage, page, info.PublishedAt)
resp, code := requestGithubAPI(url, http.MethodGet, nil, g.Token)
if code != http.StatusOK {
printGithubErrorInfo(resp)
}
var res []CommitInfo
err := json.Unmarshal(resp, &res)
if err != nil {
fatal(err)
}
list = append(list, res...)
if len(res) < prePage {
break
}
page++
}
return list
}
func printGithubErrorInfo(body []byte) {
errorInfo := &ErrorInfo{}
err := json.Unmarshal(body, errorInfo)
if err != nil {
fatal(err)
}
fatal(errors.New(errorInfo.Message))
}
func requestGithubAPI(url string, method string, body io.Reader, token string) ([]byte, int) {
cli := &http.Client{Timeout: 60 * time.Second}
request, err := http.NewRequest(method, url, body)
if err != nil {
fatal(err)
}
if token != "" {
request.Header.Add("Authorization", token)
}
resp, err := cli.Do(request)
if err != nil {
fatal(err)
}
defer resp.Body.Close()
resBody, err := io.ReadAll(resp.Body)
if err != nil {
fatal(err)
}
return resBody, resp.StatusCode
}
func ParseCommitsInfo(info []CommitInfo) string {
group := map[string][]string{
"fix": {},
"feat": {},
"deps": {},
"build": {},
"break": {},
"chore": {},
"other": {},
}
for _, commitInfo := range info {
msg := commitInfo.Commit.Message
index := strings.Index(fmt.Sprintf("%q", msg), `\n`)
if index != -1 {
msg = msg[:index-1]
}
prefix := []string{"fix", "feat", "build", "deps", "break", "chore"}
var matched bool
for _, v := range prefix {
msg = strings.TrimPrefix(msg, " ")
if strings.HasPrefix(msg, v) {
group[v] = append(group[v], msg)
matched = true
}
}
if !matched {
group["other"] = append(group["other"], msg)
}
}
md := make(map[string]string)
for key, value := range group {
var text string
switch key {
case "break":
text = "### Breaking Changes\n"
case "deps":
text = "### Dependencies\n"
case "feat":
text = "### New Features\n"
case "fix":
text = "### Bug Fixes\n"
case "build":
text = "### Builds\n"
case "chore":
text = "### Chores\n"
case "other":
text = "### Others\n"
}
if len(value) == 0 {
continue
}
md[key] += text
for _, value := range value {
md[key] += fmt.Sprintf("- %s\n", value)
}
}
return fmt.Sprint(md["break"], md["deps"], md["feat"], md["fix"], md["build"], md["chore"], md["other"])
}
func ParseReleaseInfo(info ReleaseInfo) string {
reg := regexp.MustCompile(`(?m)^\s*$[\r\n]*|[\r\n]+\s+\z|<[\S\s]+?>`)
body := reg.ReplaceAll([]byte(info.Body), []byte(""))
if string(body) == "" {
body = []byte("no release info")
}
splitters := "--------------------------------------------"
return fmt.Sprintf(
"Author: %s\nDate: %s\nUrl: %s\n\n%s\n\n%s\n\n%s\n",
info.Author.Login,
info.PublishedAt,
info.HTMLURL,
splitters,
body,
splitters,
)
}
func ParseGithubURL(url string) (owner string, repo string) {
var start int
start = strings.Index(url, "//")
if start == -1 {
start = strings.Index(url, ":") + 1
} else {
start += 2
}
end := strings.LastIndex(url, "/")
gitIndex := strings.LastIndex(url, ".git")
if gitIndex == -1 {
repo = url[strings.LastIndex(url, "/")+1:]
} else {
repo = url[strings.LastIndex(url, "/")+1 : gitIndex]
}
tmp := url[start:end]
owner = tmp[strings.Index(tmp, "/")+1:]
return
}
func fatal(err error) {
fmt.Fprintf(os.Stderr, "\033[31mERROR: %s\033[m\n", err)
os.Exit(1)
}
================================================
FILE: cmd/kratos/internal/change/get_test.go
================================================
package change
import "testing"
func TestParseGithubURL(t *testing.T) {
urls := []struct {
url string
owner string
repo string
}{
{"https://github.com/go-kratos/kratos.git", "go-kratos", "kratos"},
{"https://github.com/go-kratos/kratos", "go-kratos", "kratos"},
{"git@github.com:go-kratos/kratos.git", "go-kratos", "kratos"},
{"https://github.com/go-kratos/go-kratos.dev.git", "go-kratos", "go-kratos.dev"},
}
for _, url := range urls {
owner, repo := ParseGithubURL(url.url)
if owner != url.owner {
t.Fatalf("owner want: %s, got: %s", owner, url.owner)
}
if repo != url.repo {
t.Fatalf("repo want: %s, got: %s", repo, url.repo)
}
}
}
================================================
FILE: cmd/kratos/internal/project/add.go
================================================
package project
import (
"context"
"fmt"
"os"
"path/filepath"
"github.com/AlecAivazis/survey/v2"
"github.com/fatih/color"
"github.com/go-kratos/kratos/cmd/kratos/v2/internal/base"
)
var repoAddIgnores = []string{
".git", ".github", "api", "README.md", "LICENSE", "go.mod", "go.sum", "third_party", "openapi.yaml", ".gitignore",
}
func (p *Project) Add(ctx context.Context, dir string, layout string, branch string, mod string, pkgPath string) error {
to := filepath.Join(dir, p.Name)
if _, err := os.Stat(to); !os.IsNotExist(err) {
fmt.Printf("🚫 %s already exists\n", p.Name)
override := false
prompt := &survey.Confirm{
Message: "📂 Do you want to override the folder ?",
Help: "Delete the existing folder and create the project.",
}
e := survey.AskOne(prompt, &override)
if e != nil {
return e
}
if !override {
return err
}
os.RemoveAll(to)
}
fmt.Printf("🚀 Add service %s, layout repo is %s, please wait a moment.\n\n", p.Name, layout)
pkgPath = fmt.Sprintf("%s/%s", mod, pkgPath)
repo := base.NewRepo(layout, branch)
err := repo.CopyToV2(ctx, to, pkgPath, repoAddIgnores, []string{filepath.Join(p.Path, "api"), "api"})
if err != nil {
return err
}
e := os.Rename(
filepath.Join(to, "cmd", "server"),
filepath.Join(to, "cmd", p.Name),
)
if e != nil {
if !os.IsNotExist(e) {
return e
}
}
base.Tree(to, dir)
fmt.Printf("\n🍺 Repository creation succeeded %s\n", color.GreenString(p.Name))
fmt.Print("💻 Use the following command to add a project 👇:\n\n")
fmt.Println(color.WhiteString("$ cd %s", p.Name))
fmt.Println(color.WhiteString("$ go generate ./..."))
fmt.Println(color.WhiteString("$ go build -o ./bin/ ./... "))
fmt.Println(color.WhiteString("$ ./bin/%s -conf ./configs\n", p.Name))
fmt.Println(" 🤝 Thanks for using Kratos")
fmt.Println(" 📚 Tutorial: https://go-kratos.dev/docs/getting-started/start")
return nil
}
================================================
FILE: cmd/kratos/internal/project/new.go
================================================
package project
import (
"context"
"fmt"
"os"
"path/filepath"
"github.com/AlecAivazis/survey/v2"
"github.com/fatih/color"
"github.com/go-kratos/kratos/cmd/kratos/v2/internal/base"
)
// Project is a project template.
type Project struct {
Name string
Path string
}
// New new a project from remote repo.
func (p *Project) New(ctx context.Context, dir string, layout string, branch string) error {
to := filepath.Join(dir, p.Name)
if _, err := os.Stat(to); !os.IsNotExist(err) {
fmt.Printf("🚫 %s already exists\n", p.Name)
prompt := &survey.Confirm{
Message: "📂 Do you want to override the folder ?",
Help: "Delete the existing folder and create the project.",
}
var override bool
e := survey.AskOne(prompt, &override)
if e != nil {
return e
}
if !override {
return err
}
os.RemoveAll(to)
}
fmt.Printf("🚀 Creating service %s, layout repo is %s, please wait a moment.\n\n", p.Name, layout)
repo := base.NewRepo(layout, branch)
if err := repo.CopyTo(ctx, to, p.Name, []string{".git", ".github"}); err != nil {
return err
}
e := os.Rename(
filepath.Join(to, "cmd", "server"),
filepath.Join(to, "cmd", p.Name),
)
if e != nil {
if !os.IsNotExist(e) {
return e
}
}
base.Tree(to, dir)
fmt.Printf("\n🍺 Project creation succeeded %s\n", color.GreenString(p.Name))
fmt.Print("💻 Use the following command to start the project 👇:\n\n")
fmt.Println(color.WhiteString("$ cd %s", p.Name))
fmt.Println(color.WhiteString("$ go generate ./..."))
fmt.Println(color.WhiteString("$ go build -o ./bin/ ./... "))
fmt.Println(color.WhiteString("$ ./bin/%s -conf ./configs\n", p.Name))
fmt.Println(" 🤝 Thanks for using Kratos")
fmt.Println(" 📚 Tutorial: https://go-kratos.dev/docs/getting-started/start")
return nil
}
================================================
FILE: cmd/kratos/internal/project/project.go
================================================
package project
import (
"context"
"errors"
"fmt"
"os"
"path/filepath"
"strings"
"time"
"github.com/AlecAivazis/survey/v2"
"github.com/charmbracelet/huh"
"github.com/spf13/cobra"
"github.com/go-kratos/kratos/cmd/kratos/v2/internal/base"
)
var projects = map[string]string{
"service": "https://github.com/go-kratos/kratos-layout.git",
"admin": "https://github.com/go-kratos/kratos-admin.git",
}
// CmdNew represents the new command.
var CmdNew = &cobra.Command{
Use: "new",
Short: "Create a service template",
Long: "Create a service project using the repository template. Example: kratos new helloworld",
Run: run,
}
var (
nomod bool
repo string
branch string
timeout = "60s"
)
func init() {
CmdNew.Flags().StringVarP(&repo, "repo", "r", repo, "custom repo url")
CmdNew.Flags().StringVarP(&branch, "branch", "b", branch, "repo branch")
CmdNew.Flags().StringVarP(&timeout, "timeout", "t", timeout, "time out")
CmdNew.Flags().BoolVarP(&nomod, "nomod", "", nomod, "retain go mod")
}
func run(_ *cobra.Command, args []string) {
wd, err := os.Getwd()
if err != nil {
panic(err)
}
t, err := time.ParseDuration(timeout)
if err != nil {
panic(err)
}
ctx, cancel := context.WithTimeout(context.Background(), t)
defer cancel()
name := ""
if len(args) == 0 {
prompt := &survey.Input{
Message: "What is project name ?",
Help: "Created project name.",
}
err = survey.AskOne(prompt, &name)
if err != nil || name == "" {
return
}
} else {
name = args[0]
}
projectName, workingDir := processProjectParams(name, wd)
p := &Project{Name: projectName}
done := make(chan error, 1)
var repoURL string
if repo != "" {
repoURL = repo
} else {
repoURL, err = selectRepo()
if err != nil {
fmt.Fprintf(os.Stderr, "\033[31mERROR: failed to select repo(%s)\033[m\n", err.Error())
return
}
}
go func() {
if !nomod {
done <- p.New(ctx, workingDir, repoURL, branch)
return
}
projectRoot := getgomodProjectRoot(workingDir)
if gomodIsNotExistIn(projectRoot) {
done <- fmt.Errorf("🚫 go.mod don't exists in %s", projectRoot)
return
}
packagePath, e := filepath.Rel(projectRoot, filepath.Join(workingDir, projectName))
if e != nil {
done <- fmt.Errorf("🚫 failed to get relative path: %v", e)
return
}
packagePath = strings.ReplaceAll(packagePath, "\\", "/")
mod, e := base.ModulePath(filepath.Join(projectRoot, "go.mod"))
if e != nil {
done <- fmt.Errorf("🚫 failed to parse `go.mod`: %v", e)
return
}
// Get the relative path for adding a project based on Go modules
p.Path = filepath.Join(strings.TrimPrefix(workingDir, projectRoot+"/"), p.Name)
done <- p.Add(ctx, workingDir, repoURL, branch, mod, packagePath)
}()
select {
case <-ctx.Done():
if errors.Is(ctx.Err(), context.DeadlineExceeded) {
fmt.Fprint(os.Stderr, "\033[31mERROR: project creation timed out\033[m\n")
return
}
fmt.Fprintf(os.Stderr, "\033[31mERROR: failed to create project(%s)\033[m\n", ctx.Err().Error())
case err = <-done:
if err != nil {
fmt.Fprintf(os.Stderr, "\033[31mERROR: Failed to create project(%s)\033[m\n", err.Error())
}
}
}
func processProjectParams(projectName string, workingDir string) (projectNameResult, workingDirResult string) {
_projectDir := projectName
_workingDir := workingDir
// Process ProjectName with system variable
if strings.HasPrefix(projectName, "~") {
homeDir, err := os.UserHomeDir()
if err != nil {
// cannot get user home return fallback place dir
return _projectDir, _workingDir
}
_projectDir = filepath.Join(homeDir, projectName[2:])
}
// check path is relative
if !filepath.IsAbs(projectName) {
absPath, err := filepath.Abs(projectName)
if err != nil {
return _projectDir, _workingDir
}
_projectDir = absPath
}
return filepath.Base(_projectDir), filepath.Dir(_projectDir)
}
func getgomodProjectRoot(dir string) string {
if dir == filepath.Dir(dir) {
return dir
}
if gomodIsNotExistIn(dir) {
return getgomodProjectRoot(filepath.Dir(dir))
}
return dir
}
func gomodIsNotExistIn(dir string) bool {
_, e := os.Stat(filepath.Join(dir, "go.mod"))
return os.IsNotExist(e)
}
func selectRepo() (string, error) {
var (
choice string
customURL string
)
form := huh.NewForm(
// 1) Select group (always visible)
huh.NewGroup(
huh.NewSelect[string]().
Title("Select a template").
Options(
huh.NewOption("Service", "service"),
huh.NewOption("Admin", "admin"),
huh.NewOption("Custom (enter repo URL)", "custom"),
).
Value(&choice),
),
// 2) Input group (only visible when choice == "custom")
huh.NewGroup(
huh.NewInput().
Title("Enter custom repository URL").
Placeholder("https://github.com/owner/repo.git").
Value(&customURL).
Validate(func(s string) error {
s = strings.TrimSpace(s)
if s == "" {
return fmt.Errorf("repo URL cannot be empty")
}
return nil
}),
).WithHideFunc(func() bool {
return choice != "custom"
}),
)
if err := form.Run(); err != nil {
panic(err)
}
if choice == "custom" {
return strings.TrimSpace(customURL), nil
}
return projects[choice], nil
}
================================================
FILE: cmd/kratos/internal/project/project_linux_test.go
================================================
//go:build linux
package project
import (
"testing"
)
func Test_processProjectParams(t *testing.T) {
type args struct {
projectName string
fallbackPlaceDir string
}
tests := []struct {
name string
args args
want string
}{
{"absLinux", args{projectName: "/home/kratos/awesome/go/demo", fallbackPlaceDir: ""}, "/home/kratos/awesome/go"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if _, got := processProjectParams(tt.args.projectName, tt.args.fallbackPlaceDir); got != tt.want {
t.Errorf("processProjectParams() = %v, want %v", got, tt.want)
}
})
}
}
================================================
FILE: cmd/kratos/internal/project/project_test.go
================================================
package project
import (
"fmt"
"go/parser"
"go/token"
"os"
"path/filepath"
"testing"
"github.com/go-kratos/kratos/cmd/kratos/v2/internal/base"
)
// TestCmdNew tests the `kratos new` command.
func TestCmdNew(t *testing.T) {
cwd := changeCurrentDir(t)
projectName := "helloworld"
// create a new project
CmdNew.SetArgs([]string{projectName})
if err := CmdNew.Execute(); err != nil {
t.Fatalf("executing command: %v", err)
}
// check that the expected files were created
for _, file := range []string{
"go.mod",
"go.sum",
"README.md",
"cmd/helloworld/main.go",
} {
if _, err := os.Stat(filepath.Join(cwd, projectName, file)); err != nil {
t.Errorf("expected file %s to exist", file)
}
}
// check that the go.mod file contains the expected module name
assertGoMod(t, filepath.Join(cwd, projectName, "go.mod"), projectName)
assertImportsInclude(t, filepath.Join(cwd, projectName, "cmd", projectName, "wire.go"), fmt.Sprintf(`"%s/internal/biz"`, projectName))
}
// TestCmdNewNoMod tests the `kratos new` command with the --nomod flag.
func TestCmdNewNoMod(t *testing.T) {
cwd := changeCurrentDir(t)
// create a new project
CmdNew.SetArgs([]string{"project"})
if err := CmdNew.Execute(); err != nil {
t.Fatalf("executing command: %v", err)
}
// add new app with --nomod flag
CmdNew.SetArgs([]string{"--nomod", "project/app/user"})
if err := CmdNew.Execute(); err != nil {
t.Fatalf("executing command: %v", err)
}
// check that the expected files were created
for _, file := range []string{
"go.mod",
"go.sum",
"README.md",
"cmd/project/main.go",
"app/user/cmd/user/main.go",
} {
if _, err := os.Stat(filepath.Join(cwd, "project", file)); err != nil {
t.Errorf("expected file %s to exist", file)
}
}
assertImportsInclude(t, filepath.Join(cwd, "project/app/user/cmd/user/wire.go"), `"project/app/user/internal/biz"`)
}
// assertImportsInclude checks that the file at path contains the expected import.
func assertImportsInclude(t *testing.T, path, expected string) {
t.Helper()
got, err := imports(path)
if err != nil {
t.Fatalf("getting imports: %v", err)
}
for _, imp := range got {
if imp == expected {
return
}
}
t.Errorf("expected imports to include %s, got %v", expected, got)
}
// imports returns the imports in the file at path.
func imports(path string) ([]string, error) {
fset := token.NewFileSet()
f, err := parser.ParseFile(fset, path, nil, parser.ImportsOnly)
if err != nil {
return nil, err
}
imports := make([]string, 0, len(f.Imports))
for _, s := range f.Imports {
imports = append(imports, s.Path.Value)
}
return imports, nil
}
// assertGoMod checks that the go.mod file contains the expected module name.
func assertGoMod(t *testing.T, path, expected string) {
t.Helper()
got, err := base.ModulePath(path)
if err != nil {
t.Fatalf("getting module path: %v", err)
}
if got != expected {
t.Errorf("expected module name %s, got %s", expected, got)
}
}
// change the working directory to the tempdir
func changeCurrentDir(t *testing.T) string {
t.Helper()
tmp := t.TempDir()
oldCWD, err := os.Getwd()
if err != nil {
t.Fatalf("getting working directory: %v", err)
}
if err := os.Chdir(tmp); err != nil {
t.Fatalf("changing working directory: %v", err)
}
t.Cleanup(func() {
if err := os.Chdir(oldCWD); err != nil {
t.Fatalf("restoring working directory: %v", err)
}
})
return tmp
}
================================================
FILE: cmd/kratos/internal/project/project_windows_test.go
================================================
//go:build windows
package project
import (
"testing"
)
func Test_processProjectParams(t *testing.T) {
type args struct {
projectName string
fallbackPlaceDir string
}
tests := []struct {
name string
args args
want string
}{
{"absWindows", args{projectName: "c:\\kratos\\awesome\\go\\demo", fallbackPlaceDir: ""}, "c:\\kratos\\awesome\\go"},
//{"relativeWindows", args{projectName: "/home/kratos/awesome/go/demo", fallbackPlaceDir: ""}, "/home/kratos/awesome/go"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if _, got := processProjectParams(tt.args.projectName, tt.args.fallbackPlaceDir); got != tt.want {
t.Errorf("getProjectPlaceDir() = %v, want %v", got, tt.want)
}
})
}
}
================================================
FILE: cmd/kratos/internal/proto/add/add.go
================================================
package add
import (
"fmt"
"os"
"strings"
"github.com/spf13/cobra"
"golang.org/x/mod/modfile"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)
// CmdAdd represents the add command.
var CmdAdd = &cobra.Command{
Use: "add",
Short: "Add a proto API template",
Long: "Add a proto API template. Example: kratos proto add helloworld/v1/hello.proto",
Run: run,
}
func run(_ *cobra.Command, args []string) {
if len(args) == 0 {
fmt.Println("Please enter the proto file or directory")
return
}
input := args[0]
n := strings.LastIndex(input, "/")
if n == -1 {
fmt.Println("The proto path needs to be hierarchical.")
return
}
path := input[:n]
fileName := input[n+1:]
pkgName := strings.ReplaceAll(path, "/", ".")
p := &Proto{
Name: fileName,
Path: path,
Package: pkgName,
GoPackage: goPackage(path),
JavaPackage: javaPackage(pkgName),
Service: serviceName(fileName),
}
if err := p.Generate(); err != nil {
fmt.Println(err)
return
}
}
func modName() string {
modBytes, err := os.ReadFile("go.mod")
if err != nil {
if modBytes, err = os.ReadFile("../go.mod"); err != nil {
return ""
}
}
return modfile.ModulePath(modBytes)
}
func goPackage(path string) string {
s := strings.Split(path, "/")
return modName() + "/" + path + ";" + s[len(s)-1]
}
func javaPackage(name string) string {
return name
}
func serviceName(name string) string {
return toUpperCamelCase(strings.Split(name, ".")[0])
}
func toUpperCamelCase(s string) string {
s = strings.ReplaceAll(s, "_", " ")
s = cases.Title(language.Und, cases.NoLower).String(s)
return strings.ReplaceAll(s, " ", "")
}
================================================
FILE: cmd/kratos/internal/proto/add/add_test.go
================================================
package add
import "testing"
func TestUnderscoreToUpperCamelCase(t *testing.T) {
tests := []struct {
name string
want string
}{
{
name: "hello_world",
want: "HelloWorld",
},
{
name: "v2_kratos_dev",
want: "V2KratosDev",
},
{
name: "www_Google_com",
want: "WwwGoogleCom",
},
{
name: "wwwBaidu_com",
want: "WwwBaiduCom",
},
{
name: "HelloWorld",
want: "HelloWorld",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := toUpperCamelCase(tt.name); got != tt.want {
t.Errorf("toUpperCamelCase() = %v, want %v", got, tt.want)
}
})
}
}
================================================
FILE: cmd/kratos/internal/proto/add/proto.go
================================================
package add
import (
"fmt"
"os"
"path/filepath"
)
// Proto is a proto generator.
type Proto struct {
Name string
Path string
Service string
Package string
GoPackage string
JavaPackage string
}
// Generate generate a proto template.
func (p *Proto) Generate() error {
body, err := p.execute()
if err != nil {
return err
}
wd, err := os.Getwd()
if err != nil {
panic(err)
}
to := filepath.Join(wd, p.Path)
if _, err := os.Stat(to); os.IsNotExist(err) {
if err := os.MkdirAll(to, 0o700); err != nil {
return err
}
}
name := filepath.Join(to, p.Name)
if _, err := os.Stat(name); !os.IsNotExist(err) {
return fmt.Errorf("%s already exists", p.Name)
}
return os.WriteFile(name, body, 0o644)
}
================================================
FILE: cmd/kratos/internal/proto/add/template.go
================================================
package add
import (
"bytes"
"strings"
"text/template"
)
const protoTemplate = `
syntax = "proto3";
package {{.Package}};
option go_package = "{{.GoPackage}}";
option java_multiple_files = true;
option java_package = "{{.JavaPackage}}";
service {{.Service}} {
rpc Create{{.Service}} (Create{{.Service}}Request) returns (Create{{.Service}}Reply);
rpc Update{{.Service}} (Update{{.Service}}Request) returns (Update{{.Service}}Reply);
rpc Delete{{.Service}} (Delete{{.Service}}Request) returns (Delete{{.Service}}Reply);
rpc Get{{.Service}} (Get{{.Service}}Request) returns (Get{{.Service}}Reply);
rpc List{{.Service}} (List{{.Service}}Request) returns (List{{.Service}}Reply);
}
message Create{{.Service}}Request {}
message Create{{.Service}}Reply {}
message Update{{.Service}}Request {}
message Update{{.Service}}Reply {}
message Delete{{.Service}}Request {}
message Delete{{.Service}}Reply {}
message Get{{.Service}}Request {}
message Get{{.Service}}Reply {}
message List{{.Service}}Request {}
message List{{.Service}}Reply {}
`
func (p *Proto) execute() ([]byte, error) {
buf := new(bytes.Buffer)
tmpl, err := template.New("proto").Parse(strings.TrimSpace(protoTemplate))
if err != nil {
return nil, err
}
if err := tmpl.Execute(buf, p); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
================================================
FILE: cmd/kratos/internal/proto/client/client.go
================================================
package client
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"regexp"
"strings"
"github.com/spf13/cobra"
"github.com/go-kratos/kratos/cmd/kratos/v2/internal/base"
)
// CmdClient represents the source command.
var CmdClient = &cobra.Command{
Use: "client",
Short: "Generate the proto client code",
Long: "Generate the proto client code. Example: kratos proto client helloworld.proto",
Run: run,
}
var protoPath string
func init() {
if protoPath = os.Getenv("KRATOS_PROTO_PATH"); protoPath == "" {
protoPath = "./third_party"
}
CmdClient.Flags().StringVarP(&protoPath, "proto_path", "p", protoPath, "proto path")
}
func run(_ *cobra.Command, args []string) {
if len(args) == 0 {
fmt.Println("Please enter the proto file or directory")
return
}
var (
err error
proto = strings.TrimSpace(args[0])
)
if err = look("protoc-gen-go", "protoc-gen-go-grpc", "protoc-gen-go-http", "protoc-gen-go-errors", "protoc-gen-openapi"); err != nil {
// update the kratos plugins
cmd := exec.Command("kratos", "upgrade")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err = cmd.Run(); err != nil {
fmt.Println(err)
return
}
}
if strings.HasSuffix(proto, ".proto") {
err = generate(proto, args)
} else {
err = walk(proto, args)
}
if err != nil {
fmt.Println(err)
}
}
func look(name ...string) error {
for _, n := range name {
if _, err := exec.LookPath(n); err != nil {
return err
}
}
return nil
}
func walk(dir string, args []string) error {
if dir == "" {
dir = "."
}
return filepath.Walk(dir, func(path string, _ os.FileInfo, _ error) error {
if ext := filepath.Ext(path); ext != ".proto" || strings.HasPrefix(path, "third_party") {
return nil
}
return generate(path, args)
})
}
// generate is used to execute the generate command for the specified proto file
func generate(proto string, args []string) error {
input := []string{
"--proto_path=.",
}
if pathExists(protoPath) {
input = append(input, "--proto_path="+protoPath)
}
inputExt := []string{
"--proto_path=" + base.KratosMod(),
"--proto_path=" + filepath.Join(base.KratosMod(), "third_party"),
"--go_out=paths=source_relative:.",
"--go-grpc_out=paths=source_relative:.",
"--go-http_out=paths=source_relative:.",
"--go-errors_out=paths=source_relative:.",
"--openapi_out=paths=source_relative:.",
}
input = append(input, inputExt...)
protoBytes, err := os.ReadFile(proto)
if err == nil && len(protoBytes) > 0 {
if ok, _ := regexp.Match(`\n[^/]*(import)\s+"validate/validate.proto"`, protoBytes); ok {
input = append(input, "--validate_out=lang=go,paths=source_relative:.")
}
}
input = append(input, proto)
for _, a := range args {
if strings.HasPrefix(a, "-") {
input = append(input, a)
}
}
fd := exec.Command("protoc", input...)
fd.Stdout = os.Stdout
fd.Stderr = os.Stderr
fd.Dir = "."
if err := fd.Run(); err != nil {
return err
}
fmt.Printf("proto: %s\n", proto)
return nil
}
func pathExists(path string) bool {
_, err := os.Stat(path)
if err != nil {
return os.IsExist(err)
}
return true
}
================================================
FILE: cmd/kratos/internal/proto/proto.go
================================================
package proto
import (
"github.com/spf13/cobra"
"github.com/go-kratos/kratos/cmd/kratos/v2/internal/proto/add"
"github.com/go-kratos/kratos/cmd/kratos/v2/internal/proto/client"
"github.com/go-kratos/kratos/cmd/kratos/v2/internal/proto/server"
)
// CmdProto represents the proto command.
var CmdProto = &cobra.Command{
Use: "proto",
Short: "Generate the proto files",
Long: "Generate the proto files.",
}
func init() {
CmdProto.AddCommand(add.CmdAdd)
CmdProto.AddCommand(client.CmdClient)
CmdProto.AddCommand(server.CmdServer)
}
================================================
FILE: cmd/kratos/internal/proto/server/server.go
================================================
package server
import (
"fmt"
"log"
"os"
"path/filepath"
"strings"
"github.com/emicklei/proto"
"github.com/spf13/cobra"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)
// CmdServer the service command.
var CmdServer = &cobra.Command{
Use: "server",
Short: "Generate the proto server implementations",
Long: "Generate the proto server implementations. Example: kratos proto server api/xxx.proto --target-dir=internal/service",
Run: run,
}
var targetDir string
func init() {
CmdServer.Flags().StringVarP(&targetDir, "target-dir", "t", "internal/service", "generate target directory")
}
func run(_ *cobra.Command, args []string) {
if len(args) == 0 {
fmt.Fprintln(os.Stderr, "Please specify the proto file. Example: kratos proto server api/xxx.proto")
return
}
reader, err := os.Open(args[0])
if err != nil {
log.Fatal(err)
}
defer reader.Close()
parser := proto.NewParser(reader)
definition, err := parser.Parse()
if err != nil {
log.Fatal(err)
}
var (
pkg string
res []*Service
)
proto.Walk(definition,
proto.WithOption(func(o *proto.Option) {
if o.Name == "go_package" {
pkg = strings.Split(o.Constant.Source, ";")[0]
}
}),
proto.WithService(func(s *proto.Service) {
cs := &Service{
Package: pkg,
Service: serviceName(s.Name),
}
for _, e := range s.Elements {
r, ok := e.(*proto.RPC)
if !ok {
continue
}
cs.Methods = append(cs.Methods, &Method{
Service: serviceName(s.Name), Name: rpcName(r.Name), Request: parametersName(r.RequestType),
Reply: parametersName(r.ReturnsType), Type: getMethodType(r.StreamsRequest, r.StreamsReturns),
})
}
res = append(res, cs)
}),
)
if _, err := os.Stat(targetDir); os.IsNotExist(err) {
fmt.Printf("Target directory: %s does not exist\n", targetDir)
return
}
for _, s := range res {
to := filepath.Join(targetDir, strings.ToLower(s.Service)+".go")
if _, err := os.Stat(to); !os.IsNotExist(err) {
fmt.Fprintf(os.Stderr, "%s already exists: %s\n", s.Service, to)
continue
}
b, err := s.execute()
if err != nil {
log.Fatal(err)
}
if err := os.WriteFile(to, b, 0o644); err != nil {
log.Fatal(err)
}
fmt.Println(to)
}
}
func getMethodType(streamsRequest, streamsReturns bool) MethodType {
if !streamsRequest && !streamsReturns {
return unaryType
} else if streamsRequest && streamsReturns {
return twoWayStreamsType
} else if streamsRequest {
return requestStreamsType
} else if streamsReturns {
return returnsStreamsType
}
return unaryType
}
func parametersName(name string) string {
return strings.ReplaceAll(name, ".", "_")
}
func serviceName(name string) string {
return strings.TrimSuffix(toUpperCamelCase(strings.Split(name, ".")[0]), "Service")
}
func rpcName(name string) string {
return toUpperCamelCase(strings.Split(name, ".")[0])
}
func toUpperCamelCase(s string) string {
s = strings.ReplaceAll(s, "_", " ")
s = cases.Title(language.Und, cases.NoLower).String(s)
return strings.ReplaceAll(s, " ", "")
}
================================================
FILE: cmd/kratos/internal/proto/server/server_test.go
================================================
package server
import "testing"
func Test_serviceName(t *testing.T) {
type args struct {
str string
}
tests := []struct {
name string
args args
want string
}{
{
name: "serviceName on lowercase words",
args: args{str: "helloworld"},
want: "Helloworld",
},
{
name: "serviceName on uppercase words",
args: args{str: "HELLOWORLD"},
want: "HELLOWORLD",
},
{
name: "serviceName on lowercase words with spaces",
args: args{str: "hello world"},
want: "HelloWorld",
},
{
name: "serviceName on uppercase words with spaces",
args: args{str: "HELLO WORLD"},
want: "HELLOWORLD",
},
{
name: "serviceName on Lower Camel Case words",
args: args{str: "helloWorld"},
want: "HelloWorld",
},
{
name: "serviceName on Lower Camel Case words",
args: args{str: "helloWorld"},
want: "HelloWorld",
},
{
name: "serviceName on Upper Camel Case words",
args: args{str: "HelloWorld"},
want: "HelloWorld",
},
{
name: "serviceName on Upper Camel Case words",
args: args{str: "hello_world"},
want: "HelloWorld",
},
{
name: "serviceName with service suffix",
args: args{str: "HelloWorldService"},
want: "HelloWorld",
},
{
name: "serviceName with space and service suffix",
args: args{str: "Hello world service"},
want: "HelloWorld",
},
{
name: "serviceName with snake case and service suffix",
args: args{str: "hello_world_service"},
want: "HelloWorld",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := serviceName(tt.args.str); got != tt.want {
t.Errorf("serviceName() = %v, want %v", got, tt.want)
}
})
}
}
func Test_parametersName(t *testing.T) {
type args struct {
name string
}
tests := []struct {
name string
args args
want string
}{
{
name: "parametersName on not nested",
args: args{
name: "MessageResponse",
},
want: "MessageResponse",
},
{
name: "parametersName on One layer of nesting",
args: args{
name: "Message.Response",
},
want: "Message_Response",
},
{
name: "parametersName on Two layer of nesting",
args: args{
name: "Message.Message2.Response",
},
want: "Message_Message2_Response",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := parametersName(tt.args.name); got != tt.want {
t.Errorf("parametersName() = %v, want %v", got, tt.want)
}
})
}
}
================================================
FILE: cmd/kratos/internal/proto/server/template.go
================================================
package server
import (
"bytes"
"html/template"
)
//nolint:lll
var serviceTemplate = `
{{- /* delete empty line */ -}}
package service
import (
{{- if .UseContext }}
"context"
{{- end }}
{{- if .UseIO }}
"io"
{{- end }}
pb "{{ .Package }}"
{{- if .GoogleEmpty }}
"google.golang.org/protobuf/types/known/emptypb"
{{- end }}
)
type {{ .Service }}Service struct {
pb.Unimplemented{{ .Service }}Server
}
func New{{ .Service }}Service() *{{ .Service }}Service {
return &{{ .Service }}Service{}
}
{{- $s1 := "google.protobuf.Empty" }}
{{- $s2 := "google_protobuf_Empty" }}
{{ range .Methods }}
{{- if eq .Type 1 }}
func (s *{{ .Service }}Service) {{ .Name }}(ctx context.Context, req {{ if or (eq .Request $s1) (eq .Request $s2) }}*emptypb.Empty{{ else }}*pb.{{ .Request }}{{ end }}) ({{ if or (eq .Reply $s1) (eq .Reply $s2) }}*emptypb.Empty{{ else }}*pb.{{ .Reply }}{{ end }}, error) {
return {{ if or (eq .Reply $s1) (eq .Reply $s2) }}&emptypb.Empty{}{{ else }}&pb.{{ .Reply }}{}{{ end }}, nil
}
{{- else if eq .Type 2 }}
func (s *{{ .Service }}Service) {{ .Name }}(conn pb.{{ .Service }}_{{ .Name }}Server) error {
for {
req, err := conn.Recv()
if err == io.EOF {
return nil
}
if err != nil {
return err
}
err = conn.Send(&pb.{{ .Reply }}{})
if err != nil {
return err
}
}
}
{{- else if eq .Type 3 }}
func (s *{{ .Service }}Service) {{ .Name }}(conn pb.{{ .Service }}_{{ .Name }}Server) error {
for {
req, err := conn.Recv()
if err == io.EOF {
return conn.SendAndClose(&pb.{{ .Reply }}{})
}
if err != nil {
return err
}
}
}
{{- else if eq .Type 4 }}
func (s *{{ .Service }}Service) {{ .Name }}(req {{ if or (eq .Request $s1) (eq .Request $s2) }}*emptypb.Empty{{ else }}*pb.{{ .Request }}{{ end }}, conn pb.{{ .Service }}_{{ .Name }}Server) error {
for {
err := conn.Send(&pb.{{ .Reply }}{})
if err != nil {
return err
}
}
}
{{- end }}
{{- end }}
`
type MethodType uint8
const (
unaryType MethodType = 1
twoWayStreamsType MethodType = 2
requestStreamsType MethodType = 3
returnsStreamsType MethodType = 4
)
// Service is a proto service.
type Service struct {
Package string
Service string
Methods []*Method
GoogleEmpty bool
UseIO bool
UseContext bool
}
// Method is a proto method.
type Method struct {
Service string
Name string
Request string
Reply string
// type: unary or stream
Type MethodType
}
func (s *Service) execute() ([]byte, error) {
const empty = "google.protobuf.Empty"
// another empty style
const emptyV2 = "google_protobuf_Empty"
buf := new(bytes.Buffer)
for _, method := range s.Methods {
isReqEmpty := method.Request == empty || method.Request == emptyV2
isReplyEmpty := method.Reply == empty || method.Reply == emptyV2
if (method.Type == unaryType && (isReqEmpty || isReplyEmpty)) ||
(method.Type == returnsStreamsType && isReqEmpty) {
s.GoogleEmpty = true
}
if method.Type == twoWayStreamsType || method.Type == requestStreamsType {
s.UseIO = true
}
if method.Type == unaryType {
s.UseContext = true
}
}
tmpl, err := template.New("service").Parse(serviceTemplate)
if err != nil {
return nil, err
}
if err := tmpl.Execute(buf, s); err != nil {
return nil, err
}
return buf.Bytes(), nil
}
================================================
FILE: cmd/kratos/internal/run/run.go
================================================
package run
import (
"fmt"
"os"
"os/exec"
"path/filepath"
"strings"
"github.com/AlecAivazis/survey/v2"
"github.com/spf13/cobra"
)
// CmdRun run project command.
var CmdRun = &cobra.Command{
Use: "run",
Short: "Run project",
Long: "Run project. Example: kratos run",
Run: Run,
}
var targetDir string
func init() {
CmdRun.Flags().StringVarP(&targetDir, "work", "w", "", "target working directory")
}
// Run run project.
func Run(cmd *cobra.Command, args []string) {
var dir string
cmdArgs, programArgs := splitArgs(cmd, args)
if len(cmdArgs) > 0 {
dir = cmdArgs[0]
}
base, err := os.Getwd()
if err != nil {
fmt.Fprintf(os.Stderr, "\033[31mERROR: %s\033[m\n", err)
return
}
if dir == "" {
// find the directory containing the cmd/*
cmdPath, err := findCMD(base)
if err != nil {
fmt.Fprintf(os.Stderr, "\033[31mERROR: %s\033[m\n", err)
return
}
switch len(cmdPath) {
case 0:
fmt.Fprintf(os.Stderr, "\033[31mERROR: %s\033[m\n", "The cmd directory cannot be found in the current directory")
return
case 1:
for _, v := range cmdPath {
dir = v
}
default:
var cmdPaths []string
for k := range cmdPath {
cmdPaths = append(cmdPaths, k)
}
prompt := &survey.Select{
Message: "Which directory do you want to run?",
Options: cmdPaths,
PageSize: 10,
}
e := survey.AskOne(prompt, &dir)
if e != nil || dir == "" {
return
}
dir = cmdPath[dir]
}
}
fd := exec.Command("go", append([]string{"run", dir}, programArgs...)...)
fd.Stdout = os.Stdout
fd.Stderr = os.Stderr
fd.Dir = dir
changeWorkingDirectory(fd, targetDir)
if err := fd.Run(); err != nil {
fmt.Fprintf(os.Stderr, "\033[31mERROR: %s\033[m\n", err.Error())
return
}
}
func splitArgs(cmd *cobra.Command, args []string) (cmdArgs, programArgs []string) {
dashAt := cmd.ArgsLenAtDash()
if dashAt >= 0 {
return args[:dashAt], args[dashAt:]
}
return args, []string{}
}
func findCMD(base string) (map[string]string, error) {
wd, err := os.Getwd()
if err != nil {
return nil, err
}
if !strings.HasSuffix(wd, "/") {
wd += "/"
}
var root bool
next := func(dir string) (map[string]string, error) {
cmdPath := make(map[string]string)
err := filepath.Walk(dir, func(walkPath string, info os.FileInfo, _ error) error {
// multi level directory is not allowed under the cmdPath directory, so it is judged that the path ends with cmdPath.
if strings.HasSuffix(walkPath, "cmd") {
paths, err := os.ReadDir(walkPath)
if err != nil {
return err
}
for _, fileInfo := range paths {
if fileInfo.IsDir() {
abs := filepath.Join(walkPath, fileInfo.Name())
cmdPath[strings.TrimPrefix(abs, wd)] = abs
}
}
return nil
}
if info.Name() == "go.mod" {
root = true
}
return nil
})
return cmdPath, err
}
for i := 0; i < 5; i++ {
tmp := base
cmd, err := next(tmp)
if err != nil {
return nil, err
}
if len(cmd) > 0 {
return cmd, nil
}
if root {
break
}
base = filepath.Join(base, "..")
}
return map[string]string{"": base}, nil
}
func changeWorkingDirectory(cmd *exec.Cmd, targetDir string) {
targetDir = strings.TrimSpace(targetDir)
if targetDir != "" {
cmd.Dir = targetDir
}
}
================================================
FILE: cmd/kratos/internal/upgrade/upgrade.go
================================================
package upgrade
import (
"fmt"
"github.com/spf13/cobra"
"github.com/go-kratos/kratos/cmd/kratos/v2/internal/base"
)
// CmdUpgrade represents the upgrade command.
var CmdUpgrade = &cobra.Command{
Use: "upgrade",
Short: "Upgrade the kratos tools",
Long: "Upgrade the kratos tools. Example: kratos upgrade",
Run: Run,
}
// Run upgrade the kratos tools.
func Run(_ *cobra.Command, _ []string) {
err := base.GoInstall(
"github.com/go-kratos/kratos/cmd/kratos/v2@latest",
"github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2@latest",
"github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2@latest",
"google.golang.org/protobuf/cmd/protoc-gen-go@latest",
"google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest",
"github.com/google/gnostic/cmd/protoc-gen-openapi@latest",
)
if err != nil {
fmt.Println(err)
}
}
================================================
FILE: cmd/kratos/main.go
================================================
package main
import (
"log"
"github.com/spf13/cobra"
"github.com/go-kratos/kratos/cmd/kratos/v2/internal/change"
"github.com/go-kratos/kratos/cmd/kratos/v2/internal/project"
"github.com/go-kratos/kratos/cmd/kratos/v2/internal/proto"
"github.com/go-kratos/kratos/cmd/kratos/v2/internal/run"
"github.com/go-kratos/kratos/cmd/kratos/v2/internal/upgrade"
)
var rootCmd = &cobra.Command{
Use: "kratos",
Short: "Kratos: An elegant toolkit for Go microservices.",
Long: `Kratos: An elegant toolkit for Go microservices.`,
Version: release,
}
func init() {
rootCmd.AddCommand(project.CmdNew)
rootCmd.AddCommand(proto.CmdProto)
rootCmd.AddCommand(upgrade.CmdUpgrade)
rootCmd.AddCommand(change.CmdChange)
rootCmd.AddCommand(run.CmdRun)
}
func main() {
if err := rootCmd.Execute(); err != nil {
log.Fatal(err)
}
}
================================================
FILE: cmd/kratos/version.go
================================================
package main
// release is the current kratos tool version.
const release = "v2.9.2"
================================================
FILE: cmd/protoc-gen-go-errors/buf.gen.yaml
================================================
version: v2
plugins:
- remote: buf.build/protocolbuffers/go:v1.33.0
out: .
opt:
- paths=source_relative
================================================
FILE: cmd/protoc-gen-go-errors/buf.yaml
================================================
version: v2
name: buf.build/go-kratos/protoc-gen-go-errors
lint:
use:
- DEFAULT
except:
- PACKAGE_DIRECTORY_MATCH
- ENUM_VALUE_UPPER_SNAKE_CASE
- ENUM_VALUE_PREFIX
- ENUM_ZERO_VALUE_SUFFIX
- FIELD_LOWER_SNAKE_CASE
deps:
- buf.build/googleapis/googleapis
breaking:
use:
- FILE
================================================
FILE: cmd/protoc-gen-go-errors/errors/errors.pb.go
================================================
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.26.0
// protoc v3.15.7
// source: errors.proto
package errors
import (
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
descriptorpb "google.golang.org/protobuf/types/descriptorpb"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
type Error struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
Reason string `protobuf:"bytes,2,opt,name=reason,proto3" json:"reason,omitempty"`
Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"`
Metadata map[string]string `protobuf:"bytes,4,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
}
func (x *Error) Reset() {
*x = Error{}
if protoimpl.UnsafeEnabled {
mi := &file_errors_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *Error) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*Error) ProtoMessage() {}
func (x *Error) ProtoReflect() protoreflect.Message {
mi := &file_errors_proto_msgTypes[0]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use Error.ProtoReflect.Descriptor instead.
func (*Error) Descriptor() ([]byte, []int) {
return file_errors_proto_rawDescGZIP(), []int{0}
}
func (x *Error) GetCode() int32 {
if x != nil {
return x.Code
}
return 0
}
func (x *Error) GetReason() string {
if x != nil {
return x.Reason
}
return ""
}
func (x *Error) GetMessage() string {
if x != nil {
return x.Message
}
return ""
}
func (x *Error) GetMetadata() map[string]string {
if x != nil {
return x.Metadata
}
return nil
}
var file_errors_proto_extTypes = []protoimpl.ExtensionInfo{
{
ExtendedType: (*descriptorpb.EnumOptions)(nil),
ExtensionType: (*int32)(nil),
Field: 1108,
Name: "errors.default_code",
Tag: "varint,1108,opt,name=default_code",
Filename: "errors.proto",
},
{
ExtendedType: (*descriptorpb.EnumValueOptions)(nil),
ExtensionType: (*int32)(nil),
Field: 1109,
Name: "errors.code",
Tag: "varint,1109,opt,name=code",
Filename: "errors.proto",
},
}
// Extension fields to descriptorpb.EnumOptions.
var (
// optional int32 default_code = 1108;
E_DefaultCode = &file_errors_proto_extTypes[0]
)
// Extension fields to descriptorpb.EnumValueOptions.
var (
// optional int32 code = 1109;
E_Code = &file_errors_proto_extTypes[1]
)
var File_errors_proto protoreflect.FileDescriptor
var file_errors_proto_rawDesc = []byte{
0x0a, 0x0c, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x06,
0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74,
0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xc3, 0x01, 0x0a, 0x05, 0x45, 0x72, 0x72,
0x6f, 0x72, 0x12, 0x12, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e,
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x61, 0x73, 0x6f, 0x6e, 0x12, 0x18,
0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x37, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61,
0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x65, 0x72, 0x72,
0x6f, 0x72, 0x73, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61,
0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74,
0x61, 0x1a, 0x3b, 0x0a, 0x0d, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74,
0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20,
0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x3a, 0x40,
0x0a, 0x0c, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x1c,
0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xd4, 0x08, 0x20,
0x01, 0x28, 0x05, 0x52, 0x0b, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x43, 0x6f, 0x64, 0x65,
0x3a, 0x36, 0x0a, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x21, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6e, 0x75, 0x6d, 0x56,
0x61, 0x6c, 0x75, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0xd5, 0x08, 0x20, 0x01,
0x28, 0x05, 0x52, 0x04, 0x63, 0x6f, 0x64, 0x65, 0x42, 0x59, 0x0a, 0x18, 0x63, 0x6f, 0x6d, 0x2e,
0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2e, 0x65, 0x72,
0x72, 0x6f, 0x72, 0x73, 0x50, 0x01, 0x5a, 0x2c, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63,
0x6f, 0x6d, 0x2f, 0x67, 0x6f, 0x2d, 0x6b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x2f, 0x6b, 0x72, 0x61,
0x74, 0x6f, 0x73, 0x2f, 0x76, 0x32, 0x2f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x73, 0x3b, 0x65, 0x72,
0x72, 0x6f, 0x72, 0x73, 0xa2, 0x02, 0x0c, 0x4b, 0x72, 0x61, 0x74, 0x6f, 0x73, 0x45, 0x72, 0x72,
0x6f, 0x72, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
file_errors_proto_rawDescOnce sync.Once
file_errors_proto_rawDescData = file_errors_proto_rawDesc
)
func file_errors_proto_rawDescGZIP() []byte {
file_errors_proto_rawDescOnce.Do(func() {
file_errors_proto_rawDescData = protoimpl.X.CompressGZIP(file_errors_proto_rawDescData)
})
return file_errors_proto_rawDescData
}
var file_errors_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_errors_proto_goTypes = []interface{}{
(*Error)(nil), // 0: errors.Error
nil, // 1: errors.Error.MetadataEntry
(*descriptorpb.EnumOptions)(nil), // 2: google.protobuf.EnumOptions
(*descriptorpb.EnumValueOptions)(nil), // 3: google.protobuf.EnumValueOptions
}
var file_errors_proto_depIdxs = []int32{
1, // 0: errors.Error.metadata:type_name -> errors.Error.MetadataEntry
2, // 1: errors.default_code:extendee -> google.protobuf.EnumOptions
3, // 2: errors.code:extendee -> google.protobuf.EnumValueOptions
3, // [3:3] is the sub-list for method output_type
3, // [3:3] is the sub-list for method input_type
3, // [3:3] is the sub-list for extension type_name
1, // [1:3] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
}
func init() { file_errors_proto_init() }
func file_errors_proto_init() {
if File_errors_proto != nil {
return
}
if !protoimpl.UnsafeEnabled {
file_errors_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*Error); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_errors_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumExtensions: 2,
NumServices: 0,
},
GoTypes: file_errors_proto_goTypes,
DependencyIndexes: file_errors_proto_depIdxs,
MessageInfos: file_errors_proto_msgTypes,
ExtensionInfos: file_errors_proto_extTypes,
}.Build()
File_errors_proto = out.File
file_errors_proto_rawDesc = nil
file_errors_proto_goTypes = nil
file_errors_proto_depIdxs = nil
}
================================================
FILE: cmd/protoc-gen-go-errors/errors/errors.proto
================================================
syntax = "proto3";
package errors;
option go_package = "github.com/go-kratos/kratos/v2/errors;errors";
option java_multiple_files = true;
option java_package = "com.github.kratos.errors";
option objc_class_prefix = "KratosErrors";
import "google/protobuf/descriptor.proto";
message Error {
int32 code = 1;
string reason = 2;
string message = 3;
map<string, string> metadata = 4;
};
extend google.protobuf.EnumOptions {
int32 default_code = 1108;
}
extend google.protobuf.EnumValueOptions {
int32 code = 1109;
}
================================================
FILE: cmd/protoc-gen-go-errors/errors.go
================================================
package main
import (
"fmt"
"strings"
"unicode"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"google.golang.org/protobuf/compiler/protogen"
"google.golang.org/protobuf/proto"
"github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2/errors"
)
const (
errorsPackage = protogen.GoImportPath("github.com/go-kratos/kratos/v2/errors")
fmtPackage = protogen.GoImportPath("fmt")
)
var enCases = cases.Title(language.AmericanEnglish, cases.NoLower)
// generateFile generates a _errors.pb.go file containing kratos errors definitions.
func generateFile(gen *protogen.Plugin, file *protogen.File) *protogen.GeneratedFile {
if len(file.Enums) == 0 {
return nil
}
filename := file.GeneratedFilenamePrefix + "_errors.pb.go"
g := gen.NewGeneratedFile(filename, file.GoImportPath)
g.P("// Code generated by protoc-gen-go-errors. DO NOT EDIT.")
g.P()
g.P("package ", file.GoPackageName)
g.P()
g.QualifiedGoIdent(fmtPackage.Ident(""))
generateFileContent(gen, file, g)
return g
}
// generateFileContent generates the kratos errors definitions, excluding the package statement.
func generateFileContent(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile) {
if len(file.Enums) == 0 {
return
}
g.P("// This is a compile-time assertion to ensure that this generated file")
g.P("// is compatible with the kratos package it is being compiled against.")
g.P("const _ = ", errorsPackage.Ident("SupportPackageIsVersion1"))
g.P()
index := 0
for _, enum := range file.Enums {
if !genErrorsReason(gen, file, g, enum) {
index++
}
}
// If all enums do not contain 'errors.code', the current file is skipped
if index == 0 {
g.Skip()
}
}
func genErrorsReason(_ *protogen.Plugin, _ *protogen.File, g *protogen.GeneratedFile, enum *protogen.Enum) bool {
defaultCode := proto.GetExtension(enum.Desc.Options(), errors.E_DefaultCode)
code := 0
if ok := defaultCode.(int32); ok != 0 {
code = int(ok)
}
if code > 600 || code < 0 {
panic(fmt.Sprintf("Enum '%s' range must be greater than 0 and less than or equal to 600", string(enum.Desc.Name())))
}
var ew errorWrapper
for _, v := range enum.Values {
enumCode := code
eCode := proto.GetExtension(v.Desc.Options(), errors.E_Code)
if ok := eCode.(int32); ok != 0 {
enumCode = int(ok)
}
// If the current enumeration does not contain 'errors.code'
// or the code value exceeds the range, the current enum will be skipped
if enumCode > 600 || enumCode < 0 {
panic(fmt.Sprintf("Enum '%s' range must be greater than 0 and less than or equal to 600", string(v.Desc.Name())))
}
if enumCode == 0 {
continue
}
comment := v.Comments.Leading.String()
if comment == "" {
comment = v.Comments.Trailing.String()
}
err := &errorInfo{
Name: string(enum.Desc.Name()),
Value: string(v.Desc.Name()),
CamelValue: case2Camel(string(v.Desc.Name())),
HTTPCode: enumCode,
Comment: comment,
HasComment: len(comment) > 0,
}
ew.Errors = append(ew.Errors, err)
}
if len(ew.Errors) == 0 {
return true
}
g.P(ew.execute())
return false
}
func case2Camel(name string) string {
if !strings.Contains(name, "_") {
if name == strings.ToUpper(name) {
name = strings.ToLower(name)
}
return enCases.String(name)
}
strs := strings.Split(name, "_")
words := make([]string, 0, len(strs))
for _, w := range strs {
hasLower := false
for _, r := range w {
if unicode.IsLower(r) {
hasLower = true
break
}
}
if !hasLower {
w = strings.ToLower(w)
}
w = enCases.String(w)
words = append(words, w)
}
return strings.Join(words, "")
}
================================================
FILE: cmd/protoc-gen-go-errors/errorsTemplate.tpl
================================================
{{ range .Errors }}
{{ if .HasComment }}{{ .Comment }}{{ end -}}
func Is{{.CamelValue}}(err error) bool {
if err == nil {
return false
}
e := errors.FromError(err)
return e.Reason == {{ .Name }}_{{ .Value }}.String() && e.Code == {{ .HTTPCode }}
}
{{ if .HasComment }}{{ .Comment }}{{ end -}}
func Error{{ .CamelValue }}(format string, args ...interface{}) *errors.Error {
return errors.New({{ .HTTPCode }}, {{ .Name }}_{{ .Value }}.String(), fmt.Sprintf(format, args...))
}
{{- end }}
================================================
FILE: cmd/protoc-gen-go-errors/errors_test.go
================================================
package main
import "testing"
func Test_case2Camel(t *testing.T) {
type args struct {
name string
}
tests := []struct {
name string
args args
want string
}{
{
name: "snake1",
args: args{"SYSTEM_ERROR"},
want: "SystemError",
},
{
name: "snake2",
args: args{"System_Error"},
want: "SystemError",
},
{
name: "snake3",
args: args{"system_error"},
want: "SystemError",
},
{
name: "snake4",
args: args{"System_error"},
want: "SystemError",
},
{
name: "upper1",
args: args{"UNKNOWN"},
want: "Unknown",
},
{
name: "camel1",
args: args{"SystemError"},
want: "SystemError",
},
{
name: "camel2",
args: args{"systemError"},
want: "SystemError",
},
{
name: "lower1",
args: args{"system"},
want: "System",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := case2Camel(tt.args.name); got != tt.want {
t.Errorf("case2Camel() = %v, want %v", got, tt.want)
}
})
}
}
================================================
FILE: cmd/protoc-gen-go-errors/go.mod
================================================
module github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2
go 1.22
require (
golang.org/x/text v0.3.8
google.golang.org/protobuf v1.33.0
)
================================================
FILE: cmd/protoc-gen-go-errors/go.sum
================================================
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
================================================
FILE: cmd/protoc-gen-go-errors/main.go
================================================
package main
import (
"flag"
"fmt"
"google.golang.org/protobuf/compiler/protogen"
"google.golang.org/protobuf/types/pluginpb"
)
var showVersion = flag.Bool("version", false, "print the version and exit")
func main() {
flag.Parse()
if *showVersion {
fmt.Printf("protoc-gen-go-errors %v\n", release)
return
}
var flags flag.FlagSet
protogen.Options{
ParamFunc: flags.Set,
}.Run(func(gen *protogen.Plugin) error {
gen.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL)
for _, f := range gen.Files {
if !f.Generate {
continue
}
generateFile(gen, f)
}
return nil
})
}
================================================
FILE: cmd/protoc-gen-go-errors/template.go
================================================
package main
import (
"bytes"
_ "embed"
"text/template"
)
//go:embed errorsTemplate.tpl
var errorsTemplate string
type errorInfo struct {
Name string
Value string
HTTPCode int
CamelValue string
Comment string
HasComment bool
}
type errorWrapper struct {
Errors []*errorInfo
}
func (e *errorWrapper) execute() string {
buf := new(bytes.Buffer)
tmpl, err := template.New("errors").Parse(errorsTemplate)
if err != nil {
panic(err)
}
if err := tmpl.Execute(buf, e); err != nil {
panic(err)
}
return buf.String()
}
================================================
FILE: cmd/protoc-gen-go-errors/version.go
================================================
package main
// release is the current protoc-gen-go-errors version.
const release = "v2.9.2"
================================================
FILE: cmd/protoc-gen-go-http/go.mod
================================================
module github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2
go 1.22
require (
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd
google.golang.org/protobuf v1.33.0
)
================================================
FILE: cmd/protoc-gen-go-http/go.sum
================================================
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjV
gitextract_rshunaq6/ ├── .github/ │ ├── FUNDING.yml │ ├── ISSUE_TEMPLATE/ │ │ ├── bug-report.md │ │ ├── config.yml │ │ ├── feature-request.md │ │ ├── proposal.md │ │ └── question.md │ ├── dependabot.yml │ ├── pull_request_template.md │ ├── semantic.yml │ ├── stable.yml │ └── workflows/ │ ├── codeql-analysis.yml │ ├── comment-check.yml │ ├── gitee-sync.yml │ ├── go.yml │ ├── issue-translator.yml │ └── lint.yml ├── .gitignore ├── .golangci.yml ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── README.md ├── README_zh.md ├── ROADMAP.md ├── SECURITY.md ├── api/ │ ├── README.md │ └── metadata/ │ ├── metadata.pb.go │ ├── metadata.proto │ ├── metadata_grpc.pb.go │ ├── metadata_http.pb.go │ └── server.go ├── app.go ├── app_test.go ├── cmd/ │ ├── kratos/ │ │ ├── go.mod │ │ ├── go.sum │ │ ├── internal/ │ │ │ ├── base/ │ │ │ │ ├── install.go │ │ │ │ ├── mod.go │ │ │ │ ├── mod_test.go │ │ │ │ ├── path.go │ │ │ │ ├── repo.go │ │ │ │ ├── repo_test.go │ │ │ │ ├── vcs_url.go │ │ │ │ └── vcs_url_test.go │ │ │ ├── change/ │ │ │ │ ├── change.go │ │ │ │ ├── get.go │ │ │ │ └── get_test.go │ │ │ ├── project/ │ │ │ │ ├── add.go │ │ │ │ ├── new.go │ │ │ │ ├── project.go │ │ │ │ ├── project_linux_test.go │ │ │ │ ├── project_test.go │ │ │ │ └── project_windows_test.go │ │ │ ├── proto/ │ │ │ │ ├── add/ │ │ │ │ │ ├── add.go │ │ │ │ │ ├── add_test.go │ │ │ │ │ ├── proto.go │ │ │ │ │ └── template.go │ │ │ │ ├── client/ │ │ │ │ │ └── client.go │ │ │ │ ├── proto.go │ │ │ │ └── server/ │ │ │ │ ├── server.go │ │ │ │ ├── server_test.go │ │ │ │ └── template.go │ │ │ ├── run/ │ │ │ │ └── run.go │ │ │ └── upgrade/ │ │ │ └── upgrade.go │ │ ├── main.go │ │ └── version.go │ ├── protoc-gen-go-errors/ │ │ ├── buf.gen.yaml │ │ ├── buf.yaml │ │ ├── errors/ │ │ │ ├── errors.pb.go │ │ │ └── errors.proto │ │ ├── errors.go │ │ ├── errorsTemplate.tpl │ │ ├── errors_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── main.go │ │ ├── template.go │ │ └── version.go │ └── protoc-gen-go-http/ │ ├── go.mod │ ├── go.sum │ ├── http.go │ ├── httpTemplate.tpl │ ├── http_test.go │ ├── main.go │ ├── template.go │ └── version.go ├── codecov.yml ├── config/ │ ├── README.md │ ├── config.go │ ├── config_test.go │ ├── env/ │ │ ├── env.go │ │ ├── env_test.go │ │ ├── watcher.go │ │ └── watcher_test.go │ ├── file/ │ │ ├── file.go │ │ ├── file_test.go │ │ ├── format.go │ │ ├── format_test.go │ │ └── watcher.go │ ├── options.go │ ├── options_test.go │ ├── reader.go │ ├── reader_test.go │ ├── source.go │ ├── value.go │ └── value_test.go ├── contrib/ │ ├── config/ │ │ ├── apollo/ │ │ │ ├── README.md │ │ │ ├── apollo.go │ │ │ ├── apollo_test.go │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── parser.go │ │ │ ├── watcher.go │ │ │ └── watcher_test.go │ │ ├── consul/ │ │ │ ├── README.md │ │ │ ├── config.go │ │ │ ├── config_test.go │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── watcher.go │ │ ├── etcd/ │ │ │ ├── README.md │ │ │ ├── config.go │ │ │ ├── config_test.go │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── watcher.go │ │ ├── kubernetes/ │ │ │ ├── README.md │ │ │ ├── config.go │ │ │ ├── config_test.go │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── watcher.go │ │ │ └── watcher_test.go │ │ ├── nacos/ │ │ │ ├── README.md │ │ │ ├── config.go │ │ │ ├── config_test.go │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── watcher.go │ │ └── polaris/ │ │ ├── README.md │ │ ├── config.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── polaris.yaml │ │ └── watcher.go │ ├── encoding/ │ │ └── msgpack/ │ │ ├── go.mod │ │ ├── go.sum │ │ ├── msgpack.go │ │ └── msgpack_test.go │ ├── errortracker/ │ │ └── sentry/ │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── sentry.go │ │ └── sentry_test.go │ ├── log/ │ │ ├── aliyun/ │ │ │ ├── aliyun.go │ │ │ ├── aliyun_test.go │ │ │ ├── go.mod │ │ │ └── go.sum │ │ ├── fluent/ │ │ │ ├── fluent.go │ │ │ ├── fluent_test.go │ │ │ ├── go.mod │ │ │ └── go.sum │ │ ├── logrus/ │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── logrus.go │ │ │ └── logrus_test.go │ │ ├── tencent/ │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── tencent.go │ │ │ └── tencent_test.go │ │ ├── zap/ │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── zap.go │ │ │ └── zap_test.go │ │ └── zerolog/ │ │ ├── go.mod │ │ ├── go.sum │ │ ├── zerolog.go │ │ └── zerolog_test.go │ ├── middleware/ │ │ └── validate/ │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── internal/ │ │ │ └── testdata/ │ │ │ ├── generate.go │ │ │ ├── test.pb.go │ │ │ ├── test.pb.validate.go │ │ │ └── test.proto │ │ ├── validate.go │ │ └── validate_test.go │ ├── opensergo/ │ │ ├── README.md │ │ ├── go.mod │ │ ├── go.sum │ │ ├── opensergo.go │ │ └── opensergo_test.go │ ├── polaris/ │ │ ├── config.go │ │ ├── config_test.go │ │ ├── go.mod │ │ ├── go.sum │ │ ├── limiter.go │ │ ├── polaris.go │ │ ├── ratelimit.go │ │ ├── registry.go │ │ ├── registry_test.go │ │ ├── router.go │ │ └── router_test.go │ ├── registry/ │ │ ├── consul/ │ │ │ ├── client.go │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── registry.go │ │ │ ├── registry_test.go │ │ │ ├── service.go │ │ │ └── watcher.go │ │ ├── discovery/ │ │ │ ├── README.md │ │ │ ├── discovery.go │ │ │ ├── discovery_helper.go │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── impl_discover.go │ │ │ └── impl_registrar.go │ │ ├── etcd/ │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── registry.go │ │ │ ├── registry_test.go │ │ │ ├── service.go │ │ │ └── watcher.go │ │ ├── eureka/ │ │ │ ├── client.go │ │ │ ├── eureka.go │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── register.go │ │ │ ├── register_test.go │ │ │ └── watcher.go │ │ ├── kubernetes/ │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── registry.go │ │ │ └── registry_test.go │ │ ├── nacos/ │ │ │ ├── README.md │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── registry.go │ │ │ ├── registry_test.go │ │ │ └── watcher.go │ │ ├── polaris/ │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ └── registry.go │ │ ├── servicecomb/ │ │ │ ├── README.md │ │ │ ├── go.mod │ │ │ ├── go.sum │ │ │ ├── registry.go │ │ │ ├── registry_test.go │ │ │ └── watcher.go │ │ └── zookeeper/ │ │ ├── go.mod │ │ ├── go.sum │ │ ├── register.go │ │ ├── register_test.go │ │ ├── service.go │ │ └── watcher.go │ └── transport/ │ └── mcp/ │ ├── README.md │ ├── go.mod │ ├── go.sum │ ├── server.go │ └── server_test.go ├── docs/ │ ├── README.md │ └── design/ │ └── kratos-v2.md ├── encoding/ │ ├── README.md │ ├── encoding.go │ ├── encoding_test.go │ ├── form/ │ │ ├── form.go │ │ ├── form_test.go │ │ ├── proto_decode.go │ │ ├── proto_decode_test.go │ │ ├── proto_encode.go │ │ ├── proto_encode_test.go │ │ ├── well_known_types.go │ │ └── well_known_types_test.go │ ├── json/ │ │ ├── json.go │ │ └── json_test.go │ ├── proto/ │ │ ├── proto.go │ │ └── proto_test.go │ ├── xml/ │ │ ├── xml.go │ │ └── xml_test.go │ └── yaml/ │ ├── yaml.go │ └── yaml_test.go ├── errors/ │ ├── errors.go │ ├── errors.pb.go │ ├── errors.proto │ ├── errors_test.go │ ├── types.go │ ├── types_test.go │ ├── wrap.go │ └── wrap_test.go ├── go.mod ├── go.sum ├── hack/ │ ├── .lintcheck_failures │ ├── .test_ignored_files │ ├── resolve-modules.sh │ ├── tools.sh │ └── util.sh ├── internal/ │ ├── README.md │ ├── context/ │ │ ├── context.go │ │ └── context_test.go │ ├── endpoint/ │ │ ├── endpoint.go │ │ └── endpoint_test.go │ ├── group/ │ │ ├── example_test.go │ │ ├── group.go │ │ └── group_test.go │ ├── host/ │ │ ├── host.go │ │ └── host_test.go │ ├── httputil/ │ │ ├── http.go │ │ └── http_test.go │ ├── matcher/ │ │ ├── middleware.go │ │ └── middleware_test.go │ └── testdata/ │ ├── binding/ │ │ ├── generate.go │ │ ├── test.pb.go │ │ └── test.proto │ ├── complex/ │ │ ├── complex.pb.go │ │ ├── complex.proto │ │ └── generate.go │ ├── encoding/ │ │ ├── test.pb.go │ │ └── test.proto │ └── helloworld/ │ ├── generate.go │ ├── helloworld.pb.go │ ├── helloworld.proto │ ├── helloworld_grpc.pb.go │ └── helloworld_http.pb.go ├── log/ │ ├── README.md │ ├── filter.go │ ├── filter_test.go │ ├── global.go │ ├── global_test.go │ ├── helper.go │ ├── helper_test.go │ ├── helper_writer.go │ ├── helper_writer_test.go │ ├── level.go │ ├── level_test.go │ ├── log.go │ ├── log_test.go │ ├── std.go │ ├── std_test.go │ ├── value.go │ └── value_test.go ├── metadata/ │ ├── metadata.go │ └── metadata_test.go ├── middleware/ │ ├── auth/ │ │ └── jwt/ │ │ ├── jwt.go │ │ └── jwt_test.go │ ├── circuitbreaker/ │ │ ├── circuitbreaker.go │ │ └── circuitbreaker_test.go │ ├── logging/ │ │ ├── logging.go │ │ └── logging_test.go │ ├── metadata/ │ │ ├── metadata.go │ │ └── metadata_test.go │ ├── metrics/ │ │ ├── metrics.go │ │ ├── metrics_test.go │ │ └── otel.go │ ├── middleware.go │ ├── middleware_test.go │ ├── ratelimit/ │ │ ├── ratelimit.go │ │ └── ratelimit_test.go │ ├── recovery/ │ │ ├── recovery.go │ │ └── recovery_test.go │ ├── selector/ │ │ ├── selector.go │ │ └── selector_test.go │ ├── tracing/ │ │ ├── metadata.go │ │ ├── metadata_test.go │ │ ├── span.go │ │ ├── span_test.go │ │ ├── statshandler.go │ │ ├── statshandler_test.go │ │ ├── tracer.go │ │ ├── tracer_test.go │ │ ├── tracing.go │ │ └── tracing_test.go │ └── validate/ │ ├── validate.go │ └── validate_test.go ├── options.go ├── options_test.go ├── registry/ │ ├── README.md │ └── registry.go ├── selector/ │ ├── balancer.go │ ├── default_node.go │ ├── default_selector.go │ ├── filter/ │ │ ├── version.go │ │ └── version_test.go │ ├── filter.go │ ├── global.go │ ├── node/ │ │ ├── direct/ │ │ │ ├── direct.go │ │ │ └── direct_test.go │ │ └── ewma/ │ │ ├── node.go │ │ └── node_test.go │ ├── options.go │ ├── p2c/ │ │ ├── p2c.go │ │ └── p2c_test.go │ ├── peer.go │ ├── peer_test.go │ ├── random/ │ │ ├── random.go │ │ └── random_test.go │ ├── selector.go │ ├── selector_test.go │ └── wrr/ │ ├── wrr.go │ └── wrr_test.go ├── third_party/ │ ├── README.md │ ├── buf/ │ │ └── validate/ │ │ ├── README.md │ │ └── validate.proto │ ├── buf.yaml │ ├── errors/ │ │ └── errors.proto │ ├── google/ │ │ ├── api/ │ │ │ ├── annotations.proto │ │ │ ├── client.proto │ │ │ ├── field_behavior.proto │ │ │ ├── http.proto │ │ │ └── httpbody.proto │ │ └── protobuf/ │ │ └── descriptor.proto │ └── validate/ │ ├── README.md │ └── validate.proto ├── transport/ │ ├── grpc/ │ │ ├── balancer.go │ │ ├── balancer_test.go │ │ ├── client.go │ │ ├── client_test.go │ │ ├── codec.go │ │ ├── codec_test.go │ │ ├── interceptor.go │ │ ├── resolver/ │ │ │ ├── direct/ │ │ │ │ ├── builder.go │ │ │ │ ├── builder_test.go │ │ │ │ ├── resolver.go │ │ │ │ └── resolver_test.go │ │ │ └── discovery/ │ │ │ ├── builder.go │ │ │ ├── builder_test.go │ │ │ ├── resolver.go │ │ │ └── resolver_test.go │ │ ├── server.go │ │ ├── server_test.go │ │ ├── transport.go │ │ └── transport_test.go │ ├── http/ │ │ ├── binding/ │ │ │ ├── bind.go │ │ │ ├── bind_test.go │ │ │ ├── encode.go │ │ │ └── encode_test.go │ │ ├── calloption.go │ │ ├── calloption_test.go │ │ ├── client.go │ │ ├── client_test.go │ │ ├── codec.go │ │ ├── codec_go1.20.go │ │ ├── codec_test.go │ │ ├── context.go │ │ ├── context_test.go │ │ ├── filter.go │ │ ├── pprof/ │ │ │ └── pprof.go │ │ ├── redirect.go │ │ ├── redirect_test.go │ │ ├── resolver.go │ │ ├── resolver_test.go │ │ ├── router.go │ │ ├── router_test.go │ │ ├── server.go │ │ ├── server_test.go │ │ ├── status/ │ │ │ ├── status.go │ │ │ └── status_test.go │ │ ├── transport.go │ │ └── transport_test.go │ ├── transport.go │ └── transport_test.go └── version.go
Showing preview only (230K chars total). Download the full file or copy to clipboard to get everything.
SYMBOL INDEX (2765 symbols across 314 files)
FILE: api/metadata/metadata.pb.go
constant _ (line 20) | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
constant _ (line 22) | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
type ListServicesRequest (line 25) | type ListServicesRequest struct
method Reset (line 31) | func (x *ListServicesRequest) Reset() {
method String (line 40) | func (x *ListServicesRequest) String() string {
method ProtoMessage (line 44) | func (*ListServicesRequest) ProtoMessage() {}
method ProtoReflect (line 46) | func (x *ListServicesRequest) ProtoReflect() protoreflect.Message {
method Descriptor (line 59) | func (*ListServicesRequest) Descriptor() ([]byte, []int) {
type ListServicesReply (line 63) | type ListServicesReply struct
method Reset (line 72) | func (x *ListServicesReply) Reset() {
method String (line 81) | func (x *ListServicesReply) String() string {
method ProtoMessage (line 85) | func (*ListServicesReply) ProtoMessage() {}
method ProtoReflect (line 87) | func (x *ListServicesReply) ProtoReflect() protoreflect.Message {
method Descriptor (line 100) | func (*ListServicesReply) Descriptor() ([]byte, []int) {
method GetServices (line 104) | func (x *ListServicesReply) GetServices() []string {
method GetMethods (line 111) | func (x *ListServicesReply) GetMethods() []string {
type GetServiceDescRequest (line 118) | type GetServiceDescRequest struct
method Reset (line 126) | func (x *GetServiceDescRequest) Reset() {
method String (line 135) | func (x *GetServiceDescRequest) String() string {
method ProtoMessage (line 139) | func (*GetServiceDescRequest) ProtoMessage() {}
method ProtoReflect (line 141) | func (x *GetServiceDescRequest) ProtoReflect() protoreflect.Message {
method Descriptor (line 154) | func (*GetServiceDescRequest) Descriptor() ([]byte, []int) {
method GetName (line 158) | func (x *GetServiceDescRequest) GetName() string {
type GetServiceDescReply (line 165) | type GetServiceDescReply struct
method Reset (line 173) | func (x *GetServiceDescReply) Reset() {
method String (line 182) | func (x *GetServiceDescReply) String() string {
method ProtoMessage (line 186) | func (*GetServiceDescReply) ProtoMessage() {}
method ProtoReflect (line 188) | func (x *GetServiceDescReply) ProtoReflect() protoreflect.Message {
method Descriptor (line 201) | func (*GetServiceDescReply) Descriptor() ([]byte, []int) {
method GetFileDescSet (line 205) | func (x *GetServiceDescReply) GetFileDescSet() *descriptorpb.FileDescr...
function file_metadata_metadata_proto_rawDescGZIP (line 264) | func file_metadata_metadata_proto_rawDescGZIP() []byte {
function init (line 292) | func init() { file_metadata_metadata_proto_init() }
function file_metadata_metadata_proto_init (line 293) | func file_metadata_metadata_proto_init() {
FILE: api/metadata/metadata_grpc.pb.go
constant _ (line 19) | _ = grpc.SupportPackageIsVersion7
type MetadataClient (line 24) | type MetadataClient interface
type metadataClient (line 31) | type metadataClient struct
method ListServices (line 39) | func (c *metadataClient) ListServices(ctx context.Context, in *ListSer...
method GetServiceDesc (line 48) | func (c *metadataClient) GetServiceDesc(ctx context.Context, in *GetSe...
function NewMetadataClient (line 35) | func NewMetadataClient(cc grpc.ClientConnInterface) MetadataClient {
type MetadataServer (line 60) | type MetadataServer interface
type UnimplementedMetadataServer (line 69) | type UnimplementedMetadataServer struct
method ListServices (line 72) | func (UnimplementedMetadataServer) ListServices(context.Context, *List...
method GetServiceDesc (line 75) | func (UnimplementedMetadataServer) GetServiceDesc(context.Context, *Ge...
method mustEmbedUnimplementedMetadataServer (line 78) | func (UnimplementedMetadataServer) mustEmbedUnimplementedMetadataServe...
type UnsafeMetadataServer (line 83) | type UnsafeMetadataServer interface
function RegisterMetadataServer (line 87) | func RegisterMetadataServer(s grpc.ServiceRegistrar, srv MetadataServer) {
function _Metadata_ListServices_Handler (line 91) | func _Metadata_ListServices_Handler(srv interface{}, ctx context.Context...
function _Metadata_GetServiceDesc_Handler (line 109) | func _Metadata_GetServiceDesc_Handler(srv interface{}, ctx context.Conte...
FILE: api/metadata/metadata_http.pb.go
constant _ (line 18) | _ = http.SupportPackageIsVersion1
type MetadataHTTPServer (line 20) | type MetadataHTTPServer interface
function RegisterMetadataHTTPServer (line 25) | func RegisterMetadataHTTPServer(s *http.Server, srv MetadataHTTPServer) {
function _Metadata_ListServices0_HTTP_Handler (line 31) | func _Metadata_ListServices0_HTTP_Handler(srv MetadataHTTPServer) func(c...
function _Metadata_GetServiceDesc0_HTTP_Handler (line 50) | func _Metadata_GetServiceDesc0_HTTP_Handler(srv MetadataHTTPServer) func...
type MetadataHTTPClient (line 72) | type MetadataHTTPClient interface
type MetadataHTTPClientImpl (line 77) | type MetadataHTTPClientImpl struct
method GetServiceDesc (line 85) | func (c *MetadataHTTPClientImpl) GetServiceDesc(ctx context.Context, i...
method ListServices (line 98) | func (c *MetadataHTTPClientImpl) ListServices(ctx context.Context, in ...
function NewMetadataHTTPClient (line 81) | func NewMetadataHTTPClient(client *http.Client) MetadataHTTPClient {
FILE: api/metadata/server.go
type Server (line 26) | type Server struct
method load (line 44) | func (s *Server) load() error {
method ListServices (line 101) | func (s *Server) ListServices(_ context.Context, _ *ListServicesReques...
method GetServiceDesc (line 125) | func (s *Server) GetServiceDesc(_ context.Context, in *GetServiceDescR...
function NewServer (line 36) | func NewServer(srv *grpc.Server) *Server {
function parseMetadata (line 142) | func parseMetadata(meta any) (*dpb.FileDescriptorProto, error) {
function decodeFileDesc (line 156) | func decodeFileDesc(enc []byte) (*dpb.FileDescriptorProto, error) {
function allDependency (line 168) | func allDependency(fd *dpb.FileDescriptorProto) ([]*dpb.FileDescriptorPr...
function decompress (line 187) | func decompress(b []byte) ([]byte, error) {
function fileDescriptorProto (line 199) | func fileDescriptorProto(path string) (*dpb.FileDescriptorProto, error) {
FILE: app.go
type AppInfo (line 21) | type AppInfo interface
type App (line 30) | type App struct
method ID (line 63) | func (a *App) ID() string { return a.opts.id }
method Name (line 66) | func (a *App) Name() string { return a.opts.name }
method Version (line 69) | func (a *App) Version() string { return a.opts.version }
method Metadata (line 72) | func (a *App) Metadata() map[string]string { return a.opts.metadata }
method Endpoint (line 75) | func (a *App) Endpoint() []string {
method Run (line 83) | func (a *App) Run() error {
method Stop (line 154) | func (a *App) Stop() (err error) {
method buildInstance (line 176) | func (a *App) buildInstance() (*registry.ServiceInstance, error) {
function New (line 39) | func New(opts ...Option) *App {
type appKey (line 201) | type appKey struct
function NewContext (line 204) | func NewContext(ctx context.Context, s AppInfo) context.Context {
function FromContext (line 209) | func FromContext(ctx context.Context) (s AppInfo, ok bool) {
FILE: app_test.go
type mockRegistry (line 17) | type mockRegistry struct
method Register (line 22) | func (r *mockRegistry) Register(_ context.Context, service *registry.S...
method Deregister (line 33) | func (r *mockRegistry) Deregister(_ context.Context, service *registry...
function TestApp (line 43) | func TestApp(t *testing.T) {
function TestApp_ID (line 76) | func TestApp_ID(t *testing.T) {
function TestApp_Name (line 84) | func TestApp_Name(t *testing.T) {
function TestApp_Version (line 92) | func TestApp_Version(t *testing.T) {
function TestApp_Metadata (line 100) | func TestApp_Metadata(t *testing.T) {
function TestApp_Endpoint (line 111) | func TestApp_Endpoint(t *testing.T) {
function TestApp_buildInstance (line 132) | func TestApp_buildInstance(t *testing.T) {
function TestApp_Context (line 185) | func TestApp_Context(t *testing.T) {
function TestApp_ContextCanceled (line 287) | func TestApp_ContextCanceled(t *testing.T) {
FILE: cmd/kratos/internal/base/install.go
function GoInstall (line 11) | func GoInstall(path ...string) error {
FILE: cmd/kratos/internal/base/mod.go
function ModulePath (line 15) | func ModulePath(filename string) (string, error) {
function ModuleVersion (line 24) | func ModuleVersion(path string) (string, error) {
function KratosMod (line 47) | func KratosMod() string {
FILE: cmd/kratos/internal/base/mod_test.go
function TestModuleVersion (line 8) | func TestModuleVersion(t *testing.T) {
function TestModulePath (line 16) | func TestModulePath(t *testing.T) {
FILE: cmd/kratos/internal/base/path.go
function kratosHome (line 14) | func kratosHome() string {
function kratosHomeWithDir (line 28) | func kratosHomeWithDir(dir string) string {
function copyFile (line 38) | func copyFile(src, dst string, replaces []string) error {
function copyDir (line 58) | func copyDir(src, dst string, replaces, ignores []string) error {
function hasSets (line 92) | func hasSets(name string, sets []string) bool {
function Tree (line 101) | func Tree(path string, dir string) {
FILE: cmd/kratos/internal/base/repo.go
type Repo (line 17) | type Repo struct
method Path (line 51) | func (r *Repo) Path() string {
method Pull (line 67) | func (r *Repo) Pull(ctx context.Context) error {
method Clone (line 85) | func (r *Repo) Clone(ctx context.Context) error {
method CopyTo (line 104) | func (r *Repo) CopyTo(ctx context.Context, to string, modPath string, ...
method CopyToV2 (line 116) | func (r *Repo) CopyToV2(ctx context.Context, to string, modPath string...
function repoDir (line 23) | func repoDir(url string) string {
function NewRepo (line 42) | func NewRepo(url string, branch string) *Repo {
FILE: cmd/kratos/internal/base/repo_test.go
function TestRepo (line 9) | func TestRepo(t *testing.T) {
function TestRepoClone (line 40) | func TestRepoClone(t *testing.T) {
FILE: cmd/kratos/internal/base/vcs_url.go
function ParseVCSUrl (line 18) | func ParseVCSUrl(repo string) (*url.URL, error) {
FILE: cmd/kratos/internal/base/vcs_url_test.go
function TestParseVCSUrl (line 9) | func TestParseVCSUrl(t *testing.T) {
function TestParseSsh (line 44) | func TestParseSsh(t *testing.T) {
FILE: cmd/kratos/internal/change/change.go
function init (line 23) | func init() {
function run (line 31) | func run(_ *cobra.Command, args []string) {
FILE: cmd/kratos/internal/change/get.go
type ReleaseInfo (line 15) | type ReleaseInfo struct
type CommitInfo (line 24) | type CommitInfo struct
type ErrorInfo (line 30) | type ErrorInfo struct
type GithubAPI (line 34) | type GithubAPI struct
method GetReleaseInfo (line 41) | func (g *GithubAPI) GetReleaseInfo(version string) ReleaseInfo {
method GetCommitsInfo (line 59) | func (g *GithubAPI) GetCommitsInfo() []CommitInfo {
function printGithubErrorInfo (line 84) | func printGithubErrorInfo(body []byte) {
function requestGithubAPI (line 93) | func requestGithubAPI(url string, method string, body io.Reader, token s...
function ParseCommitsInfo (line 114) | func ParseCommitsInfo(info []CommitInfo) string {
function ParseReleaseInfo (line 175) | func ParseReleaseInfo(info ReleaseInfo) string {
function ParseGithubURL (line 193) | func ParseGithubURL(url string) (owner string, repo string) {
function fatal (line 213) | func fatal(err error) {
FILE: cmd/kratos/internal/change/get_test.go
function TestParseGithubURL (line 5) | func TestParseGithubURL(t *testing.T) {
FILE: cmd/kratos/internal/project/add.go
method Add (line 19) | func (p *Project) Add(ctx context.Context, dir string, layout string, br...
FILE: cmd/kratos/internal/project/new.go
type Project (line 16) | type Project struct
method New (line 22) | func (p *Project) New(ctx context.Context, dir string, layout string, ...
FILE: cmd/kratos/internal/project/project.go
function init (line 39) | func init() {
function run (line 46) | func run(_ *cobra.Command, args []string) {
function processProjectParams (line 124) | func processProjectParams(projectName string, workingDir string) (projec...
function getgomodProjectRoot (line 149) | func getgomodProjectRoot(dir string) string {
function gomodIsNotExistIn (line 159) | func gomodIsNotExistIn(dir string) bool {
function selectRepo (line 164) | func selectRepo() (string, error) {
FILE: cmd/kratos/internal/project/project_linux_test.go
function Test_processProjectParams (line 9) | func Test_processProjectParams(t *testing.T) {
FILE: cmd/kratos/internal/project/project_test.go
function TestCmdNew (line 15) | func TestCmdNew(t *testing.T) {
function TestCmdNewNoMod (line 44) | func TestCmdNewNoMod(t *testing.T) {
function assertImportsInclude (line 76) | func assertImportsInclude(t *testing.T, path, expected string) {
function imports (line 94) | func imports(path string) ([]string, error) {
function assertGoMod (line 110) | func assertGoMod(t *testing.T, path, expected string) {
function changeCurrentDir (line 124) | func changeCurrentDir(t *testing.T) string {
FILE: cmd/kratos/internal/project/project_windows_test.go
function Test_processProjectParams (line 9) | func Test_processProjectParams(t *testing.T) {
FILE: cmd/kratos/internal/proto/add/add.go
function run (line 22) | func run(_ *cobra.Command, args []string) {
function modName (line 51) | func modName() string {
function goPackage (line 61) | func goPackage(path string) string {
function javaPackage (line 66) | func javaPackage(name string) string {
function serviceName (line 70) | func serviceName(name string) string {
function toUpperCamelCase (line 74) | func toUpperCamelCase(s string) string {
FILE: cmd/kratos/internal/proto/add/add_test.go
function TestUnderscoreToUpperCamelCase (line 5) | func TestUnderscoreToUpperCamelCase(t *testing.T) {
FILE: cmd/kratos/internal/proto/add/proto.go
type Proto (line 10) | type Proto struct
method Generate (line 20) | func (p *Proto) Generate() error {
FILE: cmd/kratos/internal/proto/add/template.go
constant protoTemplate (line 9) | protoTemplate = `
method execute (line 42) | func (p *Proto) execute() ([]byte, error) {
FILE: cmd/kratos/internal/proto/client/client.go
function init (line 26) | func init() {
function run (line 33) | func run(_ *cobra.Command, args []string) {
function look (line 62) | func look(name ...string) error {
function walk (line 71) | func walk(dir string, args []string) error {
function generate (line 84) | func generate(proto string, args []string) error {
function pathExists (line 124) | func pathExists(path string) bool {
FILE: cmd/kratos/internal/proto/proto.go
function init (line 18) | func init() {
FILE: cmd/kratos/internal/proto/server/server.go
function init (line 25) | func init() {
function run (line 29) | func run(_ *cobra.Command, args []string) {
function getMethodType (line 95) | func getMethodType(streamsRequest, streamsReturns bool) MethodType {
function parametersName (line 108) | func parametersName(name string) string {
function serviceName (line 112) | func serviceName(name string) string {
function rpcName (line 116) | func rpcName(name string) string {
function toUpperCamelCase (line 120) | func toUpperCamelCase(s string) string {
FILE: cmd/kratos/internal/proto/server/server_test.go
function Test_serviceName (line 5) | func Test_serviceName(t *testing.T) {
function Test_parametersName (line 79) | func Test_parametersName(t *testing.T) {
FILE: cmd/kratos/internal/proto/server/template.go
type MethodType (line 88) | type MethodType
constant unaryType (line 91) | unaryType MethodType = 1
constant twoWayStreamsType (line 92) | twoWayStreamsType MethodType = 2
constant requestStreamsType (line 93) | requestStreamsType MethodType = 3
constant returnsStreamsType (line 94) | returnsStreamsType MethodType = 4
type Service (line 98) | type Service struct
method execute (line 119) | func (s *Service) execute() ([]byte, error) {
type Method (line 109) | type Method struct
FILE: cmd/kratos/internal/run/run.go
function init (line 23) | func init() {
function Run (line 28) | func Run(cmd *cobra.Command, args []string) {
function splitArgs (line 82) | func splitArgs(cmd *cobra.Command, args []string) (cmdArgs, programArgs ...
function findCMD (line 90) | func findCMD(base string) (map[string]string, error) {
function changeWorkingDirectory (line 140) | func changeWorkingDirectory(cmd *exec.Cmd, targetDir string) {
FILE: cmd/kratos/internal/upgrade/upgrade.go
function Run (line 20) | func Run(_ *cobra.Command, _ []string) {
FILE: cmd/kratos/main.go
function init (line 22) | func init() {
function main (line 30) | func main() {
FILE: cmd/kratos/version.go
constant release (line 4) | release = "v2.9.2"
FILE: cmd/protoc-gen-go-errors/errors.go
constant errorsPackage (line 18) | errorsPackage = protogen.GoImportPath("github.com/go-kratos/kratos/v2/er...
constant fmtPackage (line 19) | fmtPackage = protogen.GoImportPath("fmt")
function generateFile (line 25) | func generateFile(gen *protogen.Plugin, file *protogen.File) *protogen.G...
function generateFileContent (line 41) | func generateFileContent(gen *protogen.Plugin, file *protogen.File, g *p...
function genErrorsReason (line 62) | func genErrorsReason(_ *protogen.Plugin, _ *protogen.File, g *protogen.G...
function case2Camel (line 110) | func case2Camel(name string) string {
FILE: cmd/protoc-gen-go-errors/errors/errors.pb.go
constant _ (line 19) | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
constant _ (line 21) | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
type Error (line 24) | type Error struct
method Reset (line 35) | func (x *Error) Reset() {
method String (line 44) | func (x *Error) String() string {
method ProtoMessage (line 48) | func (*Error) ProtoMessage() {}
method ProtoReflect (line 50) | func (x *Error) ProtoReflect() protoreflect.Message {
method Descriptor (line 63) | func (*Error) Descriptor() ([]byte, []int) {
method GetCode (line 67) | func (x *Error) GetCode() int32 {
method GetReason (line 74) | func (x *Error) GetReason() string {
method GetMessage (line 81) | func (x *Error) GetMessage() string {
method GetMetadata (line 88) | func (x *Error) GetMetadata() map[string]string {
function file_errors_proto_rawDescGZIP (line 166) | func file_errors_proto_rawDescGZIP() []byte {
function init (line 191) | func init() { file_errors_proto_init() }
function file_errors_proto_init (line 192) | func file_errors_proto_init() {
FILE: cmd/protoc-gen-go-errors/errors_test.go
function Test_case2Camel (line 5) | func Test_case2Camel(t *testing.T) {
FILE: cmd/protoc-gen-go-errors/main.go
function main (line 13) | func main() {
FILE: cmd/protoc-gen-go-errors/template.go
type errorInfo (line 12) | type errorInfo struct
type errorWrapper (line 21) | type errorWrapper struct
method execute (line 25) | func (e *errorWrapper) execute() string {
FILE: cmd/protoc-gen-go-errors/version.go
constant release (line 4) | release = "v2.9.2"
FILE: cmd/protoc-gen-go-http/http.go
constant contextPackage (line 19) | contextPackage = protogen.GoImportPath("context")
constant transportHTTPPackage (line 20) | transportHTTPPackage = protogen.GoImportPath("github.com/go-kratos/krato...
constant bindingPackage (line 21) | bindingPackage = protogen.GoImportPath("github.com/go-kratos/krato...
function generateFile (line 27) | func generateFile(gen *protogen.Plugin, file *protogen.File, omitempty b...
function generateFileContent (line 50) | func generateFileContent(gen *protogen.Plugin, file *protogen.File, g *p...
function genService (line 66) | func genService(_ *protogen.Plugin, file *protogen.File, g *protogen.Gen...
function hasHTTPRule (line 97) | func hasHTTPRule(services []*protogen.Service) bool {
function buildHTTPRule (line 112) | func buildHTTPRule(g *protogen.GeneratedFile, service *protogen.Service,...
function buildMethodDesc (line 175) | func buildMethodDesc(g *protogen.GeneratedFile, m *protogen.Method, meth...
function buildPathVars (line 230) | func buildPathVars(path string) (res map[string]*string) {
function replacePath (line 248) | func replacePath(name string, value string, path string) string {
function camelCaseVars (line 262) | func camelCaseVars(s string) string {
function camelCase (line 279) | func camelCase(s string) string {
function isASCIILower (line 319) | func isASCIILower(c byte) bool {
function isASCIIDigit (line 324) | func isASCIIDigit(c byte) bool {
function protocVersion (line 328) | func protocVersion(gen *protogen.Plugin) string {
constant deprecationComment (line 340) | deprecationComment = "// Deprecated: Do not use."
FILE: cmd/protoc-gen-go-http/http_test.go
function TestNoParameters (line 8) | func TestNoParameters(t *testing.T) {
function TestSingleParam (line 16) | func TestSingleParam(t *testing.T) {
function TestTwoParametersReplacement (line 27) | func TestTwoParametersReplacement(t *testing.T) {
function TestNoReplacePath (line 44) | func TestNoReplacePath(t *testing.T) {
function TestReplacePath (line 55) | func TestReplacePath(t *testing.T) {
function TestIteration (line 63) | func TestIteration(t *testing.T) {
function TestIterationMiddle (line 76) | func TestIterationMiddle(t *testing.T) {
function TestReplaceBoundary (line 89) | func TestReplaceBoundary(t *testing.T) {
FILE: cmd/protoc-gen-go-http/main.go
function main (line 17) | func main() {
FILE: cmd/protoc-gen-go-http/template.go
type serviceDesc (line 13) | type serviceDesc struct
method execute (line 38) | func (s *serviceDesc) execute() string {
type methodDesc (line 21) | type methodDesc struct
FILE: cmd/protoc-gen-go-http/version.go
constant release (line 4) | release = "v2.9.2"
FILE: config/config.go
type Observer (line 25) | type Observer
type Config (line 28) | type Config interface
type config (line 36) | type config struct
method watch (line 62) | func (c *config) watch(w Watcher) {
method Load (line 96) | func (c *config) Load() error {
method Value (line 124) | func (c *config) Value(key string) Value {
method Scan (line 135) | func (c *config) Scan(v any) error {
method Watch (line 143) | func (c *config) Watch(key string, o Observer) error {
method Close (line 151) | func (c *config) Close() error {
function New (line 45) | func New(opts ...Option) Config {
function Get (line 161) | func Get[T any](c Config, key string) (T, error) {
FILE: config/config_test.go
constant _testJSON (line 11) | _testJSON = `
type testConfigStruct (line 39) | type testConfigStruct struct
type testJSONSource (line 62) | type testJSONSource struct
method Load (line 72) | func (p *testJSONSource) Load() ([]*KeyValue, error) {
method Watch (line 81) | func (p *testJSONSource) Watch() (Watcher, error) {
function newTestJSONSource (line 68) | func newTestJSONSource(data string) *testJSONSource {
type testWatcher (line 85) | type testWatcher struct
method Next (line 95) | func (w *testWatcher) Next() ([]*KeyValue, error) {
method Stop (line 106) | func (w *testWatcher) Stop() error {
function newTestWatcher (line 91) | func newTestWatcher(sig, err chan struct{}) Watcher {
function TestConfig (line 111) | func TestConfig(t *testing.T) {
FILE: config/env/env.go
type env (line 10) | type env struct
method Load (line 18) | func (e *env) Load() (kvs []*config.KeyValue, err error) {
method load (line 22) | func (e *env) load(envs []string) []*config.KeyValue {
method Watch (line 47) | func (e *env) Watch() (config.Watcher, error) {
function NewSource (line 14) | func NewSource(prefixes ...string) config.Source {
function matchPrefix (line 55) | func matchPrefix(prefixes []string, s string) (string, bool) {
FILE: config/env/env_test.go
constant _testJSON (line 13) | _testJSON = `
function TestEnvWithPrefix (line 30) | func TestEnvWithPrefix(t *testing.T) {
function TestEnvWithoutPrefix (line 148) | func TestEnvWithoutPrefix(t *testing.T) {
function Test_env_load (line 262) | func Test_env_load(t *testing.T) {
function Test_matchPrefix (line 390) | func Test_matchPrefix(t *testing.T) {
function Test_env_watch (line 421) | func Test_env_watch(t *testing.T) {
FILE: config/env/watcher.go
type watcher (line 11) | type watcher struct
method Next (line 22) | func (w *watcher) Next() ([]*config.KeyValue, error) {
method Stop (line 27) | func (w *watcher) Stop() error {
function NewWatcher (line 16) | func NewWatcher() (config.Watcher, error) {
FILE: config/env/watcher_test.go
function Test_watcher_next (line 7) | func Test_watcher_next(t *testing.T) {
function Test_watcher_stop (line 22) | func Test_watcher_stop(t *testing.T) {
FILE: config/file/file.go
type file (line 14) | type file struct
method loadFile (line 23) | func (f *file) loadFile(path string) (*config.KeyValue, error) {
method loadDir (line 44) | func (f *file) loadDir(path string) (kvs []*config.KeyValue, err error) {
method Load (line 63) | func (f *file) Load() (kvs []*config.KeyValue, err error) {
method Watch (line 78) | func (f *file) Watch() (config.Watcher, error) {
function NewSource (line 19) | func NewSource(path string) config.Source {
FILE: config/file/file_test.go
constant _testJSON (line 16) | _testJSON = `
constant _testJSONUpdate (line 42) | _testJSONUpdate = `
function TestFile (line 85) | func TestFile(t *testing.T) {
function testWatchFile (line 104) | func testWatchFile(t *testing.T, path string) {
function testWatchDir (line 152) | func testWatchDir(t *testing.T, path, file string) {
function testSource (line 181) | func testSource(t *testing.T, path string, data []byte) {
function TestConfig (line 194) | func TestConfig(t *testing.T) {
function testConfig (line 208) | func testConfig(t *testing.T, c config.Config) {
function testScan (line 277) | func testScan(t *testing.T, c config.Config) {
function TestMergeDataRace (line 306) | func TestMergeDataRace(t *testing.T) {
FILE: config/file/format.go
function format (line 5) | func format(name string) string {
FILE: config/file/format_test.go
function TestFormat (line 7) | func TestFormat(t *testing.T) {
function BenchmarkFormat (line 53) | func BenchmarkFormat(b *testing.B) {
FILE: config/file/watcher.go
type watcher (line 15) | type watcher struct
method Next (line 35) | func (w *watcher) Next() ([]*config.KeyValue, error) {
method Stop (line 65) | func (w *watcher) Stop() error {
function newWatcher (line 23) | func newWatcher(f *file) (config.Watcher, error) {
FILE: config/options.go
type Decoder (line 13) | type Decoder
type Resolver (line 16) | type Resolver
type Merge (line 19) | type Merge
type Option (line 22) | type Option
type options (line 24) | type options struct
function WithSource (line 32) | func WithSource(s ...Source) Option {
function WithDecoder (line 43) | func WithDecoder(d Decoder) Option {
function WithResolveActualTypes (line 51) | func WithResolveActualTypes(enableConvertToType bool) Option {
function WithResolver (line 58) | func WithResolver(r Resolver) Option {
function WithMergeFunc (line 65) | func WithMergeFunc(m Merge) Option {
function defaultDecoder (line 73) | func defaultDecoder(src *KeyValue, target map[string]any) error {
function newActualTypesResolver (line 94) | func newActualTypesResolver(enableConvertToType bool) func(map[string]an...
function defaultResolver (line 103) | func defaultResolver(input map[string]any) error {
function resolver (line 108) | func resolver(input map[string]any, mapper func(name string) string, toT...
function mapper (line 138) | func mapper(input map[string]any) func(name string) string {
function convertToType (line 152) | func convertToType(input string) any {
function expand (line 184) | func expand(s string, mapping func(string) string, toType bool) any {
FILE: config/options_test.go
function TestDefaultDecoder (line 9) | func TestDefaultDecoder(t *testing.T) {
function TestDefaultResolver (line 45) | func TestDefaultResolver(t *testing.T) {
function TestNewDefaultResolver (line 202) | func TestNewDefaultResolver(t *testing.T) {
function TestExpand (line 360) | func TestExpand(t *testing.T) {
function TestWithMergeFunc (line 388) | func TestWithMergeFunc(t *testing.T) {
FILE: config/reader.go
type Reader (line 18) | type Reader interface
type reader (line 25) | type reader struct
method Merge (line 39) | func (r *reader) Merge(kvs ...*KeyValue) error {
method Value (line 61) | func (r *reader) Value(path string) (Value, bool) {
method Source (line 67) | func (r *reader) Source() ([]byte, error) {
method Resolve (line 73) | func (r *reader) Resolve() error {
method cloneMap (line 79) | func (r *reader) cloneMap() (map[string]any, error) {
function newReader (line 31) | func newReader(opts options) Reader {
function cloneMap (line 85) | func cloneMap(src map[string]any) (map[string]any, error) {
function convertMap (line 104) | func convertMap(src any) any {
function readValue (line 134) | func readValue(values map[string]any, path string) (Value, bool) {
function marshalJSON (line 160) | func marshalJSON(v any) ([]byte, error) {
function unmarshalJSON (line 167) | func unmarshalJSON(data []byte, v any) error {
FILE: config/reader_test.go
function TestReader_Merge (line 13) | func TestReader_Merge(t *testing.T) {
function TestReader_Value (line 81) | func TestReader_Value(t *testing.T) {
function TestReader_Source (line 185) | func TestReader_Source(t *testing.T) {
function TestCloneMap (line 217) | func TestCloneMap(t *testing.T) {
function TestConvertMap (line 252) | func TestConvertMap(t *testing.T) {
function TestReadValue (line 287) | func TestReadValue(t *testing.T) {
FILE: config/source.go
type KeyValue (line 4) | type KeyValue struct
type Source (line 11) | type Source interface
type Watcher (line 17) | type Watcher interface
FILE: config/value.go
type Value (line 22) | type Value interface
type atomicValue (line 35) | type atomicValue struct
method typeAssertError (line 39) | func (v *atomicValue) typeAssertError() error {
method Bool (line 43) | func (v *atomicValue) Bool() (bool, error) {
method Int (line 55) | func (v *atomicValue) Int() (int64, error) {
method Slice (line 87) | func (v *atomicValue) Slice() ([]Value, error) {
method Map (line 101) | func (v *atomicValue) Map() (map[string]Value, error) {
method Float (line 115) | func (v *atomicValue) Float() (float64, error) {
method String (line 147) | func (v *atomicValue) String() (string, error) {
method Duration (line 161) | func (v *atomicValue) Duration() (time.Duration, error) {
method Scan (line 169) | func (v *atomicValue) Scan(obj any) error {
type errValue (line 180) | type errValue struct
method Bool (line 184) | func (v errValue) Bool() (bool, error) { return false, v....
method Int (line 185) | func (v errValue) Int() (int64, error) { return 0, v.err }
method Float (line 186) | func (v errValue) Float() (float64, error) { return 0.0, v.err }
method Duration (line 187) | func (v errValue) Duration() (time.Duration, error) { return 0, v.err }
method String (line 188) | func (v errValue) String() (string, error) { return "", v.err }
method Scan (line 189) | func (v errValue) Scan(any) error { return v.err }
method Load (line 190) | func (v errValue) Load() any { return nil }
method Store (line 191) | func (v errValue) Store(any) {}
method Slice (line 192) | func (v errValue) Slice() ([]Value, error) { return nil, v.err }
method Map (line 193) | func (v errValue) Map() (map[string]Value, error) { return nil, v.err }
FILE: config/value_test.go
function TestAtomicValue_Bool (line 9) | func TestAtomicValue_Bool(t *testing.T) {
function TestAtomicValue_Int (line 47) | func TestAtomicValue_Int(t *testing.T) {
function TestAtomicValue_Float (line 72) | func TestAtomicValue_Float(t *testing.T) {
type ts (line 97) | type ts struct
method String (line 102) | func (t ts) String() string {
function TestAtomicValue_String (line 106) | func TestAtomicValue_String(t *testing.T) {
function TestAtomicValue_Duration (line 144) | func TestAtomicValue_Duration(t *testing.T) {
function TestAtomicValue_Slice (line 159) | func TestAtomicValue_Slice(t *testing.T) {
function TestAtomicValue_Map (line 178) | func TestAtomicValue_Map(t *testing.T) {
function TestAtomicValue_Scan (line 209) | func TestAtomicValue_Scan(t *testing.T) {
FILE: contrib/config/apollo/apollo.go
type apollo (line 16) | type apollo struct
method load (line 146) | func (e *apollo) load() []*config.KeyValue {
method getConfig (line 180) | func (e *apollo) getConfig(ns string) (*config.KeyValue, error) {
method getOriginConfig (line 200) | func (e apollo) getOriginConfig(ns string) (*config.KeyValue, error) {
method Load (line 213) | func (e *apollo) Load() (kv []*config.KeyValue, err error) {
method Watch (line 217) | func (e *apollo) Watch() (config.Watcher, error) {
constant yaml (line 22) | yaml = "yaml"
constant yml (line 23) | yml = "yml"
constant json (line 24) | json = "json"
constant properties (line 25) | properties = "properties"
type Option (line 31) | type Option
type options (line 33) | type options struct
function WithAppID (line 45) | func WithAppID(appID string) Option {
function WithCluster (line 52) | func WithCluster(cluster string) Option {
function WithEndpoint (line 59) | func WithEndpoint(endpoint string) Option {
function WithEnableBackup (line 66) | func WithEnableBackup() Option {
function WithDisableBackup (line 73) | func WithDisableBackup() Option {
function WithSecret (line 80) | func WithSecret(secret string) Option {
function WithNamespace (line 87) | func WithNamespace(name string) Option {
function WithBackupPath (line 94) | func WithBackupPath(backupPath string) Option {
function WithOriginalConfig (line 101) | func WithOriginalConfig() Option {
function NewSource (line 110) | func NewSource(opts ...Option) config.Source {
function format (line 132) | func format(ns string) string {
function resolve (line 227) | func resolve(key string, value any, target map[string]any) {
function genKey (line 260) | func genKey(ns, sub string) string {
function init (line 279) | func init() {
FILE: contrib/config/apollo/apollo_test.go
function Test_genKey (line 7) | func Test_genKey(t *testing.T) {
function Test_format (line 51) | func Test_format(t *testing.T) {
FILE: contrib/config/apollo/parser.go
type jsonExtParser (line 3) | type jsonExtParser struct
method Parse (line 5) | func (parser jsonExtParser) Parse(configContent any) (map[string]any, ...
type yamlExtParser (line 9) | type yamlExtParser struct
method Parse (line 11) | func (parser yamlExtParser) Parse(configContent any) (map[string]any, ...
FILE: contrib/config/apollo/watcher.go
type watcher (line 14) | type watcher struct
method Next (line 92) | func (w *watcher) Next() ([]*config.KeyValue, error) {
method Stop (line 101) | func (w *watcher) Stop() error {
type customChangeListener (line 21) | type customChangeListener struct
method onChange (line 26) | func (c *customChangeListener) onChange(namespace string, changes map[...
method OnChange (line 63) | func (c *customChangeListener) OnChange(changeEvent *storage.ChangeEve...
method OnNewestChange (line 72) | func (c *customChangeListener) OnNewestChange(_ *storage.FullChangeEve...
function newWatcher (line 74) | func newWatcher(a *apollo) (config.Watcher, error) {
FILE: contrib/config/apollo/watcher_test.go
function Test_onChange (line 12) | func Test_onChange(t *testing.T) {
FILE: contrib/config/consul/config.go
type Option (line 15) | type Option
type options (line 17) | type options struct
function WithContext (line 23) | func WithContext(ctx context.Context) Option {
function WithPath (line 30) | func WithPath(p string) Option {
type source (line 36) | type source struct
method Load (line 62) | func (s *source) Load() ([]*config.KeyValue, error) {
method Watch (line 88) | func (s *source) Watch() (config.Watcher, error) {
function New (line 41) | func New(client *api.Client, opts ...Option) (config.Source, error) {
FILE: contrib/config/consul/config_test.go
constant testPath (line 13) | testPath = "kratos/test/config"
constant testKey (line 15) | testKey = "kratos/test/config/key"
function TestConfig (line 17) | func TestConfig(t *testing.T) {
function TestExtToFormat (line 68) | func TestExtToFormat(t *testing.T) {
function Test_source_Watch (line 106) | func Test_source_Watch(t *testing.T) {
function Test_source_Load (line 188) | func Test_source_Load(t *testing.T) {
FILE: contrib/config/consul/watcher.go
type watcher (line 14) | type watcher struct
method handle (line 23) | func (w *watcher) handle(_ uint64, data any) {
method Next (line 90) | func (w *watcher) Next() ([]*config.KeyValue, error) {
method Stop (line 99) | func (w *watcher) Stop() error {
function newWatcher (line 61) | func newWatcher(s *source) (*watcher, error) {
FILE: contrib/config/etcd/config.go
type Option (line 15) | type Option
type options (line 17) | type options struct
function WithContext (line 24) | func WithContext(ctx context.Context) Option {
function WithPath (line 31) | func WithPath(p string) Option {
function WithPrefix (line 38) | func WithPrefix(prefix bool) Option {
type source (line 44) | type source struct
method Load (line 71) | func (s *source) Load() ([]*config.KeyValue, error) {
method Watch (line 94) | func (s *source) Watch() (config.Watcher, error) {
function New (line 49) | func New(client *clientv3.Client, opts ...Option) (config.Source, error) {
FILE: contrib/config/etcd/config_test.go
constant testKey (line 13) | testKey = "/kratos/test/config"
function TestConfig (line 15) | func TestConfig(t *testing.T) {
function TestExtToFormat (line 70) | func TestExtToFormat(t *testing.T) {
function TestEtcdWithPath (line 113) | func TestEtcdWithPath(t *testing.T) {
function TestEtcdWithPrefix (line 142) | func TestEtcdWithPrefix(t *testing.T) {
FILE: contrib/config/etcd/watcher.go
type watcher (line 11) | type watcher struct
method Next (line 36) | func (w *watcher) Next() ([]*config.KeyValue, error) {
method Stop (line 48) | func (w *watcher) Stop() error {
function newWatcher (line 19) | func newWatcher(s *source) *watcher {
FILE: contrib/config/kubernetes/config.go
type Option (line 20) | type Option
type options (line 22) | type options struct
function Namespace (line 36) | func Namespace(ns string) Option {
function LabelSelector (line 43) | func LabelSelector(label string) Option {
function FieldSelector (line 50) | func FieldSelector(field string) Option {
function KubeConfig (line 57) | func KubeConfig(config string) Option {
function Master (line 64) | func Master(master string) Option {
type kube (line 70) | type kube struct
method init (line 86) | func (k *kube) init() (err error) {
method load (line 103) | func (k *kube) load() (kvs []*config.KeyValue, err error) {
method configMap (line 120) | func (k *kube) configMap(cm v1.ConfigMap) (kvs []*config.KeyValue) {
method Load (line 133) | func (k *kube) Load() ([]*config.KeyValue, error) {
method Watch (line 143) | func (k *kube) Watch() (config.Watcher, error) {
function NewSource (line 76) | func NewSource(opts ...Option) config.Source {
FILE: contrib/config/kubernetes/config_test.go
constant testKey (line 22) | testKey = "test_config.json"
constant namespace (line 23) | namespace = "default"
constant name (line 24) | name = "test"
function TestSource (line 38) | func TestSource(t *testing.T) {
function ExampleNewSource (line 54) | func ExampleNewSource() {
function TestConfig (line 70) | func TestConfig(t *testing.T) {
function TestExtToFormat (line 147) | func TestExtToFormat(t *testing.T) {
FILE: contrib/config/kubernetes/watcher.go
type watcher (line 14) | type watcher struct
method Next (line 33) | func (w *watcher) Next() ([]*config.KeyValue, error) {
method Stop (line 58) | func (w *watcher) Stop() error {
function newWatcher (line 19) | func newWatcher(k *kube) (config.Watcher, error) {
FILE: contrib/config/kubernetes/watcher_test.go
function TestKube (line 15) | func TestKube(t *testing.T) {
FILE: contrib/config/nacos/config.go
type Option (line 14) | type Option
type options (line 16) | type options struct
function WithGroup (line 22) | func WithGroup(group string) Option {
function WithDataID (line 29) | func WithDataID(dataID string) Option {
type Config (line 35) | type Config struct
method Load (line 48) | func (c *Config) Load() ([]*config.KeyValue, error) {
method Watch (line 66) | func (c *Config) Watch() (config.Watcher, error) {
function NewConfigSource (line 40) | func NewConfigSource(client config_client.IConfigClient, opts ...Option)...
FILE: contrib/config/nacos/config_test.go
function TestConfig_Load (line 15) | func TestConfig_Load(t *testing.T) {
function TestConfig_Watch (line 125) | func TestConfig_Watch(t *testing.T) {
FILE: contrib/config/nacos/watcher.go
type Watcher (line 13) | type Watcher struct
method Next (line 39) | func (w *Watcher) Next() ([]*config.KeyValue, error) {
method Close (line 55) | func (w *Watcher) Close() error {
method Stop (line 64) | func (w *Watcher) Stop() error {
type cancelListenConfigFunc (line 23) | type cancelListenConfigFunc
function newWatcher (line 25) | func newWatcher(ctx context.Context, dataID string, group string, cancel...
FILE: contrib/config/polaris/config.go
type Option (line 15) | type Option
type options (line 17) | type options struct
function WithNamespace (line 25) | func WithNamespace(namespace string) Option {
function WithFileGroup (line 32) | func WithFileGroup(fileGroup string) Option {
function WithFileName (line 39) | func WithFileName(fileName string) Option {
type source (line 45) | type source struct
method Load (line 76) | func (s *source) Load() ([]*config.KeyValue, error) {
method Watch (line 98) | func (s *source) Watch() (config.Watcher, error) {
function New (line 50) | func New(client polaris.ConfigAPI, opts ...Option) (config.Source, error) {
FILE: contrib/config/polaris/watcher.go
type Watcher (line 15) | type Watcher struct
method Next (line 61) | func (w *Watcher) Next() ([]*config.KeyValue, error) {
method Stop (line 73) | func (w *Watcher) Stop() error {
type eventChan (line 20) | type eventChan struct
function getFullPath (line 27) | func getFullPath(namespace string, fileGroup string, fileName string) st...
function receive (line 31) | func receive(event model.ConfigFileChangeEvent) {
function newWatcher (line 44) | func newWatcher(configFile polaris.ConfigFile) *Watcher {
FILE: contrib/encoding/msgpack/msgpack.go
constant Name (line 10) | Name = "msgpack"
function init (line 12) | func init() {
type codec (line 17) | type codec struct
method Marshal (line 19) | func (codec) Marshal(v any) ([]byte, error) {
method Unmarshal (line 23) | func (codec) Unmarshal(data []byte, v any) error {
method Name (line 27) | func (codec) Name() string {
FILE: contrib/encoding/msgpack/msgpack_test.go
type loginRequest (line 8) | type loginRequest struct
type testModel (line 13) | type testModel struct
function TestName (line 18) | func TestName(t *testing.T) {
function TestCodec (line 25) | func TestCodec(t *testing.T) {
FILE: contrib/errortracker/sentry/sentry.go
type ctxKey (line 20) | type ctxKey struct
type Option (line 22) | type Option
type options (line 24) | type options struct
function WithRepanic (line 32) | func WithRepanic(repanic bool) Option {
function WithWaitForDelivery (line 39) | func WithWaitForDelivery(waitForDelivery bool) Option {
function WithTimeout (line 46) | func WithTimeout(timeout time.Duration) Option {
function WithTags (line 53) | func WithTags(kvs map[string]any) Option {
function Server (line 60) | func Server(opts ...Option) middleware.Middleware {
function recoverWithSentry (line 109) | func recoverWithSentry(ctx context.Context, opts options, hub *sentry.Hu...
function isBrokenPipeError (line 126) | func isBrokenPipeError(err any) bool {
function GetHubFromContext (line 140) | func GetHubFromContext(ctx context.Context) *sentry.Hub {
FILE: contrib/errortracker/sentry/sentry_test.go
function TestWithTags (line 8) | func TestWithTags(t *testing.T) {
function TestWithRepanic (line 21) | func TestWithRepanic(t *testing.T) {
function TestWithWaitForDelivery (line 31) | func TestWithWaitForDelivery(t *testing.T) {
function TestWithTimeout (line 41) | func TestWithTimeout(t *testing.T) {
FILE: contrib/log/aliyun/aliyun.go
type Logger (line 17) | type Logger interface
type aliyunLog (line 24) | type aliyunLog struct
method GetProducer (line 29) | func (a *aliyunLog) GetProducer() *producer.Producer {
method Close (line 80) | func (a *aliyunLog) Close() error {
method Log (line 84) | func (a *aliyunLog) Log(level log.Level, keyvals ...any) error {
type options (line 33) | type options struct
function defaultOptions (line 41) | func defaultOptions() *options {
function WithEndpoint (line 48) | func WithEndpoint(endpoint string) Option {
function WithProject (line 54) | func WithProject(project string) Option {
function WithLogstore (line 60) | func WithLogstore(logstore string) Option {
function WithAccessKey (line 66) | func WithAccessKey(ak string) Option {
function WithAccessSecret (line 72) | func WithAccessSecret(as string) Option {
type Option (line 78) | type Option
function NewAliyunLog (line 106) | func NewAliyunLog(options ...Option) (Logger, error) {
function newString (line 129) | func newString(s string) *string {
function toString (line 134) | func toString(v any) string {
FILE: contrib/log/aliyun/aliyun_test.go
function TestWithEndpoint (line 11) | func TestWithEndpoint(t *testing.T) {
function TestWithProject (line 21) | func TestWithProject(t *testing.T) {
function TestWithLogstore (line 31) | func TestWithLogstore(t *testing.T) {
function TestWithAccessKey (line 41) | func TestWithAccessKey(t *testing.T) {
function TestWithAccessSecret (line 51) | func TestWithAccessSecret(t *testing.T) {
function TestLogger (line 61) | func TestLogger(t *testing.T) {
function TestLog (line 77) | func TestLog(t *testing.T) {
function TestNewString (line 111) | func TestNewString(t *testing.T) {
function TestToString (line 118) | func TestToString(t *testing.T) {
FILE: contrib/log/fluent/fluent.go
type Option (line 18) | type Option
type options (line 20) | type options struct
function WithTimeout (line 33) | func WithTimeout(timeout time.Duration) Option {
function WithWriteTimeout (line 40) | func WithWriteTimeout(writeTimeout time.Duration) Option {
function WithBufferLimit (line 47) | func WithBufferLimit(bufferLimit int) Option {
function WithRetryWait (line 54) | func WithRetryWait(retryWait int) Option {
function WithMaxRetry (line 61) | func WithMaxRetry(maxRetry int) Option {
function WithMaxRetryWait (line 68) | func WithMaxRetryWait(maxRetryWait int) Option {
function WithTagPrefix (line 75) | func WithTagPrefix(tagPrefix string) Option {
function WithAsync (line 82) | func WithAsync(async bool) Option {
function WithForceStopAsyncSend (line 89) | func WithForceStopAsyncSend(forceStopAsyncSend bool) Option {
type Logger (line 96) | type Logger struct
method Log (line 154) | func (l *Logger) Log(level log.Level, keyvals ...any) error {
method Close (line 175) | func (l *Logger) Close() error {
function NewLogger (line 106) | func NewLogger(addr string, opts ...Option) (*Logger, error) {
FILE: contrib/log/fluent/fluent_test.go
function TestMain (line 13) | func TestMain(m *testing.M) {
function TestWithTimeout (line 38) | func TestWithTimeout(t *testing.T) {
function TestWithWriteTimeout (line 48) | func TestWithWriteTimeout(t *testing.T) {
function TestWithBufferLimit (line 58) | func TestWithBufferLimit(t *testing.T) {
function TestWithRetryWait (line 68) | func TestWithRetryWait(t *testing.T) {
function TestWithMaxRetry (line 78) | func TestWithMaxRetry(t *testing.T) {
function TestWithMaxRetryWait (line 88) | func TestWithMaxRetryWait(t *testing.T) {
function TestWithTagPrefix (line 98) | func TestWithTagPrefix(t *testing.T) {
function TestWithAsync (line 108) | func TestWithAsync(t *testing.T) {
function TestWithForceStopAsyncSend (line 118) | func TestWithForceStopAsyncSend(t *testing.T) {
function TestLogger (line 128) | func TestLogger(t *testing.T) {
function TestLoggerWithOpt (line 142) | func TestLoggerWithOpt(t *testing.T) {
function TestLoggerError (line 157) | func TestLoggerError(t *testing.T) {
function BenchmarkLoggerPrint (line 174) | func BenchmarkLoggerPrint(b *testing.B) {
function BenchmarkLoggerHelperV (line 189) | func BenchmarkLoggerHelperV(b *testing.B) {
function BenchmarkLoggerHelperInfo (line 203) | func BenchmarkLoggerHelperInfo(b *testing.B) {
function BenchmarkLoggerHelperInfof (line 218) | func BenchmarkLoggerHelperInfof(b *testing.B) {
function BenchmarkLoggerHelperInfow (line 233) | func BenchmarkLoggerHelperInfow(b *testing.B) {
FILE: contrib/log/logrus/logrus.go
type Logger (line 11) | type Logger struct
method Log (line 21) | func (l *Logger) Log(level log.Level, keyvals ...any) (err error) {
function NewLogger (line 15) | func NewLogger(logger *logrus.Logger) log.Logger {
FILE: contrib/log/logrus/logrus_test.go
function TestLoggerLog (line 13) | func TestLoggerLog(t *testing.T) {
FILE: contrib/log/tencent/tencent.go
type Logger (line 15) | type Logger interface
type tencentLog (line 22) | type tencentLog struct
method GetProducer (line 27) | func (log *tencentLog) GetProducer() *cls.AsyncProducerClient {
method Close (line 68) | func (log *tencentLog) Close() error {
method Log (line 72) | func (log *tencentLog) Log(level log.Level, keyvals ...any) error {
type options (line 31) | type options struct
function defaultOptions (line 38) | func defaultOptions() *options {
function WithEndpoint (line 42) | func WithEndpoint(endpoint string) Option {
function WithTopicID (line 48) | func WithTopicID(topicID string) Option {
function WithAccessKey (line 54) | func WithAccessKey(ak string) Option {
function WithAccessSecret (line 60) | func WithAccessSecret(as string) Option {
type Option (line 66) | type Option
function NewLogger (line 93) | func NewLogger(options ...Option) (Logger, error) {
function newString (line 113) | func newString(s string) *string {
function toString (line 118) | func toString(v any) string {
FILE: contrib/log/tencent/tencent_test.go
function TestWithEndpoint (line 11) | func TestWithEndpoint(t *testing.T) {
function TestWithTopicId (line 21) | func TestWithTopicId(t *testing.T) {
function TestWithAccessKey (line 31) | func TestWithAccessKey(t *testing.T) {
function TestWithAccessSecret (line 41) | func TestWithAccessSecret(t *testing.T) {
function TestTestLogger (line 51) | func TestTestLogger(t *testing.T) {
function TestLog (line 72) | func TestLog(t *testing.T) {
function TestNewString (line 107) | func TestNewString(t *testing.T) {
function TestToString (line 114) | func TestToString(t *testing.T) {
FILE: contrib/log/zap/zap.go
type Logger (line 14) | type Logger struct
method Log (line 35) | func (l *Logger) Log(level log.Level, keyvals ...any) error {
method Sync (line 74) | func (l *Logger) Sync() error {
method Close (line 78) | func (l *Logger) Close() error {
type Option (line 19) | type Option
function WithMessageKey (line 22) | func WithMessageKey(key string) Option {
function NewLogger (line 28) | func NewLogger(zlog *zap.Logger) *Logger {
FILE: contrib/log/zap/zap_test.go
type testWriteSyncer (line 12) | type testWriteSyncer struct
method Write (line 16) | func (x *testWriteSyncer) Write(p []byte) (n int, err error) {
method Sync (line 21) | func (x *testWriteSyncer) Sync() error {
function TestLogger (line 25) | func TestLogger(t *testing.T) {
FILE: contrib/log/zerolog/zerolog.go
type Logger (line 11) | type Logger struct
method Log (line 21) | func (l *Logger) Log(level log.Level, keyvals ...any) (err error) {
function NewLogger (line 15) | func NewLogger(logger *zerolog.Logger) log.Logger {
FILE: contrib/log/zerolog/zerolog_test.go
type testWriteSyncer (line 11) | type testWriteSyncer struct
method Write (line 15) | func (x *testWriteSyncer) Write(p []byte) (n int, err error) {
function TestLogger (line 20) | func TestLogger(t *testing.T) {
FILE: contrib/middleware/validate/internal/testdata/test.pb.go
constant _ (line 21) | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
constant _ (line 23) | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
type Legacy (line 26) | type Legacy struct
method Reset (line 34) | func (x *Legacy) Reset() {
method String (line 41) | func (x *Legacy) String() string {
method ProtoMessage (line 45) | func (*Legacy) ProtoMessage() {}
method ProtoReflect (line 47) | func (x *Legacy) ProtoReflect() protoreflect.Message {
method Descriptor (line 60) | func (*Legacy) Descriptor() ([]byte, []int) {
method GetName (line 64) | func (x *Legacy) GetName() string {
method GetAge (line 71) | func (x *Legacy) GetAge() int32 {
type Mixed (line 78) | type Mixed struct
method Reset (line 86) | func (x *Mixed) Reset() {
method String (line 93) | func (x *Mixed) String() string {
method ProtoMessage (line 97) | func (*Mixed) ProtoMessage() {}
method ProtoReflect (line 99) | func (x *Mixed) ProtoReflect() protoreflect.Message {
method Descriptor (line 112) | func (*Mixed) Descriptor() ([]byte, []int) {
method GetName (line 116) | func (x *Mixed) GetName() string {
method GetAge (line 123) | func (x *Mixed) GetAge() int32 {
type Modern (line 130) | type Modern struct
method Reset (line 138) | func (x *Modern) Reset() {
method String (line 145) | func (x *Modern) String() string {
method ProtoMessage (line 149) | func (*Modern) ProtoMessage() {}
method ProtoReflect (line 151) | func (x *Modern) ProtoReflect() protoreflect.Message {
method Descriptor (line 164) | func (*Modern) Descriptor() ([]byte, []int) {
method GetName (line 168) | func (x *Modern) GetName() string {
method GetAge (line 175) | func (x *Modern) GetAge() int32 {
function file_test_proto_rawDescGZIP (line 215) | func file_test_proto_rawDescGZIP() []byte {
function init (line 236) | func init() { file_test_proto_init() }
function file_test_proto_init (line 237) | func file_test_proto_init() {
FILE: contrib/middleware/validate/internal/testdata/test.pb.validate.go
method Validate (line 41) | func (m *Legacy) Validate() error {
method ValidateAll (line 48) | func (m *Legacy) ValidateAll() error {
method validate (line 52) | func (m *Legacy) validate(all bool) error {
type LegacyMultiError (line 90) | type LegacyMultiError
method Error (line 93) | func (m LegacyMultiError) Error() string {
method AllErrors (line 102) | func (m LegacyMultiError) AllErrors() []error { return m }
type LegacyValidationError (line 106) | type LegacyValidationError struct
method Field (line 114) | func (e LegacyValidationError) Field() string { return e.field }
method Reason (line 117) | func (e LegacyValidationError) Reason() string { return e.reason }
method Cause (line 120) | func (e LegacyValidationError) Cause() error { return e.cause }
method Key (line 123) | func (e LegacyValidationError) Key() bool { return e.key }
method ErrorName (line 126) | func (e LegacyValidationError) ErrorName() string { return "LegacyVali...
method Error (line 129) | func (e LegacyValidationError) Error() string {
method Validate (line 161) | func (m *Mixed) Validate() error {
method ValidateAll (line 168) | func (m *Mixed) ValidateAll() error {
method validate (line 172) | func (m *Mixed) validate(all bool) error {
type MixedMultiError (line 201) | type MixedMultiError
method Error (line 204) | func (m MixedMultiError) Error() string {
method AllErrors (line 213) | func (m MixedMultiError) AllErrors() []error { return m }
type MixedValidationError (line 217) | type MixedValidationError struct
method Field (line 225) | func (e MixedValidationError) Field() string { return e.field }
method Reason (line 228) | func (e MixedValidationError) Reason() string { return e.reason }
method Cause (line 231) | func (e MixedValidationError) Cause() error { return e.cause }
method Key (line 234) | func (e MixedValidationError) Key() bool { return e.key }
method ErrorName (line 237) | func (e MixedValidationError) ErrorName() string { return "MixedValida...
method Error (line 240) | func (e MixedValidationError) Error() string {
method Validate (line 272) | func (m *Modern) Validate() error {
method ValidateAll (line 279) | func (m *Modern) ValidateAll() error {
method validate (line 283) | func (m *Modern) validate(all bool) error {
type ModernMultiError (line 303) | type ModernMultiError
method Error (line 306) | func (m ModernMultiError) Error() string {
method AllErrors (line 315) | func (m ModernMultiError) AllErrors() []error { return m }
type ModernValidationError (line 319) | type ModernValidationError struct
method Field (line 327) | func (e ModernValidationError) Field() string { return e.field }
method Reason (line 330) | func (e ModernValidationError) Reason() string { return e.reason }
method Cause (line 333) | func (e ModernValidationError) Cause() error { return e.cause }
method Key (line 336) | func (e ModernValidationError) Key() bool { return e.key }
method ErrorName (line 339) | func (e ModernValidationError) ErrorName() string { return "ModernVali...
method Error (line 342) | func (e ModernValidationError) Error() string {
FILE: contrib/middleware/validate/validate.go
type validator (line 13) | type validator interface
function ProtoValidate (line 18) | func ProtoValidate() middleware.Middleware {
FILE: contrib/middleware/validate/validate_test.go
type testcase (line 14) | type testcase struct
function TestTable (line 20) | func TestTable(t *testing.T) {
FILE: contrib/opensergo/opensergo.go
type Option (line 24) | type Option
function WithEndpoint (line 26) | func WithEndpoint(endpoint string) Option {
type options (line 32) | type options struct
method ParseJSON (line 36) | func (o *options) ParseJSON(data []byte) error {
type OpenSergo (line 40) | type OpenSergo struct
method ReportMetadata (line 78) | func (s *OpenSergo) ReportMetadata(ctx context.Context, app kratos.App...
function New (line 44) | func New(opts ...Option) (*OpenSergo, error) {
function listDescriptors (line 118) | func listDescriptors() (services []*v1.ServiceDescriptor, types []*v1.Ty...
function HTTPPatternInfo (line 187) | func HTTPPatternInfo(pattern any) (method string, path string) {
FILE: contrib/opensergo/opensergo_test.go
type testMetadataServiceServer (line 22) | type testMetadataServiceServer struct
method ReportMetadata (line 26) | func (m *testMetadataServiceServer) ReportMetadata(_ context.Context, ...
type testAppInfo (line 30) | type testAppInfo struct
method ID (line 38) | func (t testAppInfo) ID() string {
method Name (line 42) | func (t testAppInfo) Name() string {
method Version (line 46) | func (t testAppInfo) Version() string {
method Metadata (line 50) | func (t testAppInfo) Metadata() map[string]string {
method Endpoint (line 54) | func (t testAppInfo) Endpoint() []string {
function TestWithEndpoint (line 58) | func TestWithEndpoint(t *testing.T) {
function TestOptionsParseJSON (line 67) | func TestOptionsParseJSON(t *testing.T) {
function TestListDescriptors (line 80) | func TestListDescriptors(t *testing.T) {
function TestHTTPPatternInfo (line 184) | func TestHTTPPatternInfo(t *testing.T) {
function TestOpenSergo (line 269) | func TestOpenSergo(t *testing.T) {
FILE: contrib/polaris/config.go
type ConfigOption (line 16) | type ConfigOption
type configOptions (line 18) | type configOptions struct
function WithConfigFile (line 25) | func WithConfigFile(file ...File) ConfigOption {
type File (line 31) | type File struct
type source (line 36) | type source struct
method Load (line 42) | func (s *source) Load() ([]*config.KeyValue, error) {
method Watch (line 60) | func (s *source) Watch() (config.Watcher, error) {
type ConfigWatcher (line 64) | type ConfigWatcher struct
method Next (line 97) | func (w *ConfigWatcher) Next() ([]*config.KeyValue, error) {
method Stop (line 117) | func (w *ConfigWatcher) Stop() error {
function receive (line 69) | func receive(event chan model.ConfigFileChangeEvent) func(m model.Config...
function newConfigWatcher (line 80) | func newConfigWatcher(configFile []polaris.ConfigFile) *ConfigWatcher {
FILE: contrib/polaris/config_test.go
function makeJSONRequest (line 28) | func makeJSONRequest(uri string, data string, method string, headers map...
type commonRes (line 46) | type commonRes struct
type LoginRes (line 50) | type LoginRes struct
type configClient (line 57) | type configClient struct
method createConfigFile (line 91) | func (client *configClient) createConfigFile(name string) error {
method updateConfigFile (line 121) | func (client *configClient) updateConfigFile(name string) error {
method deleteConfigFile (line 150) | func (client *configClient) deleteConfigFile(name string) error {
method publishConfigFile (line 173) | func (client *configClient) publishConfigFile(name string) error {
function newConfigClient (line 61) | func newConfigClient() (*configClient, error) {
function getToken (line 71) | func getToken(testCenterURL string) (string, error) {
function TestConfig (line 200) | func TestConfig(t *testing.T) {
function TestExtToFormat (line 272) | func TestExtToFormat(t *testing.T) {
function TestGetMultipleConfig (line 322) | func TestGetMultipleConfig(t *testing.T) {
FILE: contrib/polaris/limiter.go
type LimiterOption (line 14) | type LimiterOption
type limiterOptions (line 17) | type limiterOptions struct
function WithLimiterNamespace (line 37) | func WithLimiterNamespace(namespace string) LimiterOption {
function WithLimiterService (line 44) | func WithLimiterService(service string) LimiterOption {
function WithLimiterTimeout (line 51) | func WithLimiterTimeout(timeout time.Duration) LimiterOption {
function WithLimiterRetryCount (line 58) | func WithLimiterRetryCount(retryCount int) LimiterOption {
function WithLimiterToken (line 65) | func WithLimiterToken(token uint32) LimiterOption {
type Limiter (line 71) | type Limiter struct
method Allow (line 90) | func (l *Limiter) Allow(method string, argument ...model.Argument) (ra...
function buildRequest (line 79) | func buildRequest(opts limiterOptions) polaris.QuotaRequest {
FILE: contrib/polaris/polaris.go
type Polaris (line 12) | type Polaris struct
method Config (line 55) | func (p *Polaris) Config(opts ...ConfigOption) (config.Source, error) {
method Registry (line 74) | func (p *Polaris) Registry(opts ...RegistryOption) (r *Registry) {
method Limiter (line 89) | func (p *Polaris) Limiter(opts ...LimiterOption) (r Limiter) {
type Option (line 23) | type Option
function WithNamespace (line 26) | func WithNamespace(ns string) Option {
function WithService (line 33) | func WithService(service string) Option {
function New (line 40) | func New(sdk api.SDKContext, opts ...Option) Polaris {
FILE: contrib/polaris/ratelimit.go
function Ratelimit (line 23) | func Ratelimit(l Limiter) middleware.Middleware {
FILE: contrib/polaris/registry.go
type registryOptions (line 22) | type registryOptions struct
type RegistryOption (line 53) | type RegistryOption
type Registry (line 56) | type Registry struct
method Register (line 98) | func (r *Registry) Register(_ context.Context, instance *registry.Serv...
method Deregister (line 157) | func (r *Registry) Deregister(_ context.Context, serviceInstance *regi...
method GetService (line 198) | func (r *Registry) GetService(_ context.Context, serviceName string) (...
method Watch (line 231) | func (r *Registry) Watch(ctx context.Context, serviceName string) (reg...
function WithRegistryServiceToken (line 63) | func WithRegistryServiceToken(serviceToken string) RegistryOption {
function WithRegistryWeight (line 68) | func WithRegistryWeight(weight int) RegistryOption {
function WithRegistryHealthy (line 73) | func WithRegistryHealthy(healthy bool) RegistryOption {
function WithRegistryIsolate (line 78) | func WithRegistryIsolate(isolate bool) RegistryOption {
function WithRegistryTTL (line 83) | func WithRegistryTTL(TTL int) RegistryOption {
function WithRegistryTimeout (line 88) | func WithRegistryTimeout(timeout time.Duration) RegistryOption {
function WithRegistryRetryCount (line 93) | func WithRegistryRetryCount(retryCount int) RegistryOption {
function merge (line 218) | func merge(instances []model.Instance) map[string][]model.Instance {
type Watcher (line 235) | type Watcher struct
method Next (line 274) | func (w *Watcher) Next() ([]*registry.ServiceInstance, error) {
method Stop (line 353) | func (w *Watcher) Stop() error {
function newWatcher (line 246) | func newWatcher(ctx context.Context, namespace string, serviceName strin...
function instancesToServiceInstances (line 358) | func instancesToServiceInstances(instances map[string][]model.Instance) ...
function mapClone (line 384) | func mapClone[M ~map[K]V, K comparable, V any](m M) M {
FILE: contrib/polaris/registry_test.go
function TestRegistry (line 15) | func TestRegistry(t *testing.T) {
FILE: contrib/polaris/router.go
type router (line 23) | type router struct
type RouterOption (line 27) | type RouterOption
function WithRouterService (line 30) | func WithRouterService(service string) RouterOption {
method NodeFilter (line 37) | func (p *Polaris) NodeFilter(opts ...RouterOption) selector.NodeFilter {
function buildPolarisInstance (line 108) | func buildPolarisInstance(namespace string, nodes []selector.Node) *pb.S...
FILE: contrib/polaris/router_test.go
function TestRouter (line 18) | func TestRouter(t *testing.T) {
type mockApp (line 185) | type mockApp struct
method ID (line 187) | func (m mockApp) ID() string {
method Name (line 191) | func (m mockApp) Name() string {
method Version (line 195) | func (m mockApp) Version() string {
method Metadata (line 199) | func (m mockApp) Metadata() map[string]string {
method Endpoint (line 203) | func (m mockApp) Endpoint() []string {
FILE: contrib/registry/consul/client.go
type Datacenter (line 21) | type Datacenter
constant SingleDatacenter (line 24) | SingleDatacenter Datacenter = "SINGLE"
constant MultiDatacenter (line 25) | MultiDatacenter Datacenter = "MULTI"
type Client (line 29) | type Client struct
method Service (line 93) | func (c *Client) Service(ctx context.Context, service string, index ui...
method multiDCService (line 116) | func (c *Client) multiDCService(ctx context.Context, service string, i...
method singleDCEntries (line 152) | func (c *Client) singleDCEntries(service, tag string, passingOnly bool...
method Register (line 157) | func (c *Client) Register(ctx context.Context, svc *registry.ServiceIn...
method Deregister (line 294) | func (c *Client) Deregister(ctx context.Context, serviceID string) err...
type canceler (line 51) | type canceler struct
function defaultResolver (line 57) | func defaultResolver(_ context.Context, entries []*api.ServiceEntry) []*...
type ServiceResolver (line 90) | type ServiceResolver
function sleepCtx (line 282) | func sleepCtx(ctx context.Context, d time.Duration) error {
FILE: contrib/registry/consul/registry.go
type Option (line 21) | type Option
function WithHealthCheck (line 24) | func WithHealthCheck(enable bool) Option {
function WithTimeout (line 31) | func WithTimeout(timeout time.Duration) Option {
function WithDatacenter (line 38) | func WithDatacenter(dc Datacenter) Option {
function WithHeartbeat (line 45) | func WithHeartbeat(enable bool) Option {
function WithServiceResolver (line 54) | func WithServiceResolver(fn ServiceResolver) Option {
function WithHealthCheckInterval (line 63) | func WithHealthCheckInterval(interval int) Option {
function WithDeregisterCriticalServiceAfter (line 72) | func WithDeregisterCriticalServiceAfter(interval int) Option {
function WithServiceCheck (line 81) | func WithServiceCheck(checks ...*api.AgentServiceCheck) Option {
function WithTags (line 90) | func WithTags(tags []string) Option {
type Config (line 99) | type Config struct
type Registry (line 104) | type Registry struct
method Register (line 135) | func (r *Registry) Register(ctx context.Context, svc *registry.Service...
method Deregister (line 140) | func (r *Registry) Deregister(ctx context.Context, svc *registry.Servi...
method GetService (line 145) | func (r *Registry) GetService(ctx context.Context, name string) ([]*re...
method ListServices (line 175) | func (r *Registry) ListServices() (allServices map[string][]*registry....
method Watch (line 192) | func (r *Registry) Watch(ctx context.Context, name string) (registry.W...
method resolve (line 242) | func (r *Registry) resolve(ctx context.Context, ss *serviceSet) error {
method tryDelete (line 288) | func (r *Registry) tryDelete(ss *serviceSet) bool {
function New (line 113) | func New(apiClient *api.Client, opts ...Option) *Registry {
FILE: contrib/registry/consul/registry_test.go
function tcpServer (line 22) | func tcpServer(lis net.Listener) {
function TestRegistry_Register (line 35) | func TestRegistry_Register(t *testing.T) {
function TestRegistry_GetService (line 163) | func TestRegistry_GetService(t *testing.T) {
function TestRegistry_Watch (line 308) | func TestRegistry_Watch(t *testing.T) {
function TestRegistry_IdleAndWatch (line 449) | func TestRegistry_IdleAndWatch(t *testing.T) {
function TestRegistry_IdleAndWatch2 (line 578) | func TestRegistry_IdleAndWatch2(t *testing.T) {
function TestRegistry_ExitOldResolverAndReWatch (line 692) | func TestRegistry_ExitOldResolverAndReWatch(t *testing.T) {
function TestRegistry_ShareServiceSet (line 828) | func TestRegistry_ShareServiceSet(t *testing.T) {
function TestRegistry_MultiWatch (line 904) | func TestRegistry_MultiWatch(t *testing.T) {
function getIntranetIP (line 1015) | func getIntranetIP() string {
FILE: contrib/registry/consul/service.go
type serviceSet (line 11) | type serviceSet struct
method broadcast (line 24) | func (s *serviceSet) broadcast(ss []*registry.ServiceInstance) {
method delete (line 36) | func (s *serviceSet) delete(w *watcher) {
FILE: contrib/registry/consul/watcher.go
type watcher (line 9) | type watcher struct
method Next (line 18) | func (w *watcher) Next() (services []*registry.ServiceInstance, err er...
method Stop (line 37) | func (w *watcher) Stop() error {
FILE: contrib/registry/discovery/discovery.go
type Discovery (line 19) | type Discovery struct
method Close (line 80) | func (d *Discovery) Close() error {
method selfProc (line 86) | func (d *Discovery) selfProc(resolver *Resolve, event <-chan struct{}) {
method newSelf (line 100) | func (d *Discovery) newSelf(zones map[string][]*discoveryInstance) {
method resolveBuild (line 137) | func (d *Discovery) resolveBuild(appID string) *Resolve {
method serverProc (line 172) | func (d *Discovery) serverProc() {
method pickNode (line 212) | func (d *Discovery) pickNode() string {
method switchNode (line 220) | func (d *Discovery) switchNode() {
method renew (line 225) | func (d *Discovery) renew(ctx context.Context, ins *discoveryInstance)...
method cancel (line 268) | func (d *Discovery) cancel(ins *discoveryInstance) (err error) {
method broadcast (line 306) | func (d *Discovery) broadcast(apps map[string]*disInstancesInfo) {
method polls (line 340) | func (d *Discovery) polls(ctx context.Context) (apps map[string]*disIn...
type appInfo (line 36) | type appInfo struct
function New (line 44) | func New(c *Config) *Discovery {
type Resolve (line 415) | type Resolve struct
method Watch (line 422) | func (r *Resolve) Watch() <-chan struct{} {
method fetch (line 427) | func (r *Resolve) fetch(_ context.Context) (ins *disInstancesInfo, ok ...
method Close (line 449) | func (r *Resolve) Close() error {
FILE: contrib/registry/discovery/discovery_helper.go
constant _registerURL (line 22) | _registerURL = "http://%s/discovery/register"
constant _cancelURL (line 24) | _cancelURL = "http://%s/discovery/cancel"
constant _renewURL (line 25) | _renewURL = "http://%s/discovery/renew"
constant _pollURL (line 26) | _pollURL = "http://%s/discovery/polls"
constant _codeOK (line 29) | _codeOK = 0
constant _codeNotFound (line 30) | _codeNotFound = -404
constant _codeNotModified (line 31) | _codeNotModified = -304
constant _registerGap (line 35) | _registerGap = 30 * time.Second
constant _statusUP (line 36) | _statusUP = "1"
constant _discoveryAppID (line 37) | _discoveryAppID = "infra.discovery"
type Config (line 41) | type Config struct
function fixConfig (line 49) | func fixConfig(c *Config) error {
type discoveryInstance (line 67) | type discoveryInstance struct
constant _reservedInstanceIDKey (line 81) | _reservedInstanceIDKey = "kratos.v2.serviceinstance.id"
function fromServerInstance (line 84) | func fromServerInstance(ins *registry.ServiceInstance, config *Config) *...
function toServiceInstance (line 110) | func toServiceInstance(ins *discoveryInstance) *registry.ServiceInstance {
type disInstancesInfo (line 139) | type disInstancesInfo struct
type scheduler (line 146) | type scheduler struct
type zoneStrategy (line 151) | type zoneStrategy struct
type strategy (line 156) | type strategy struct
constant _paramKeyRegion (line 161) | _paramKeyRegion = "region"
constant _paramKeyZone (line 162) | _paramKeyZone = "zone"
constant _paramKeyEnv (line 163) | _paramKeyEnv = "env"
constant _paramKeyHostname (line 164) | _paramKeyHostname = "hostname"
constant _paramKeyAppID (line 165) | _paramKeyAppID = "appid"
constant _paramKeyAddrs (line 166) | _paramKeyAddrs = "addrs"
constant _paramKeyVersion (line 167) | _paramKeyVersion = "version"
constant _paramKeyStatus (line 168) | _paramKeyStatus = "status"
constant _paramKeyMetadata (line 169) | _paramKeyMetadata = "metadata"
function newParams (line 172) | func newParams(c *Config) url.Values {
type discoveryCommonResp (line 185) | type discoveryCommonResp struct
type discoveryPollsResp (line 190) | type discoveryPollsResp struct
FILE: contrib/registry/discovery/impl_discover.go
function filterInstancesByZone (line 13) | func filterInstancesByZone(ins *disInstancesInfo, zone string) []*regist...
method GetService (line 30) | func (d *Discovery) GetService(ctx context.Context, serviceName string) ...
method Watch (line 45) | func (d *Discovery) Watch(ctx context.Context, serviceName string) (regi...
type watcher (line 53) | type watcher struct
method Next (line 60) | func (w *watcher) Next() ([]*registry.ServiceInstance, error) {
method Stop (line 86) | func (w *watcher) Stop() error {
FILE: contrib/registry/discovery/impl_registrar.go
method Register (line 16) | func (d *Discovery) Register(ctx context.Context, service *registry.Serv...
method register (line 66) | func (d *Discovery) register(ctx context.Context, ins *discoveryInstance...
method Deregister (line 125) | func (d *Discovery) Deregister(_ context.Context, service *registry.Serv...
FILE: contrib/registry/etcd/registry.go
type Option (line 20) | type Option
type options (line 22) | type options struct
function Context (line 30) | func Context(ctx context.Context) Option {
function Namespace (line 35) | func Namespace(ns string) Option {
function RegisterTTL (line 40) | func RegisterTTL(ttl time.Duration) Option {
function MaxRetry (line 44) | func MaxRetry(num int) Option {
type Registry (line 49) | type Registry struct
method Register (line 86) | func (r *Registry) Register(ctx context.Context, service *registry.Ser...
method registerKey (line 110) | func (r *Registry) registerKey(service *registry.ServiceInstance) stri...
method Deregister (line 115) | func (r *Registry) Deregister(ctx context.Context, service *registry.S...
method GetService (line 132) | func (r *Registry) GetService(ctx context.Context, name string) ([]*re...
method serviceKey (line 152) | func (r *Registry) serviceKey(name string) string {
method Watch (line 157) | func (r *Registry) Watch(ctx context.Context, name string) (registry.W...
method registerWithKV (line 163) | func (r *Registry) registerWithKV(ctx context.Context, key string, val...
method heartBeat (line 175) | func (r *Registry) heartBeat(ctx context.Context, leaseID clientv3.Lea...
type serviceCancel (line 61) | type serviceCancel struct
function New (line 67) | func New(client *clientv3.Client, opts ...Option) (r *Registry) {
FILE: contrib/registry/etcd/registry_test.go
function TestRegistry (line 16) | func TestRegistry(t *testing.T) {
function TestHeartBeat (line 81) | func TestHeartBeat(t *testing.T) {
FILE: contrib/registry/etcd/service.go
function marshal (line 9) | func marshal(si *registry.ServiceInstance) (string, error) {
function unmarshal (line 17) | func unmarshal(data []byte) (si *registry.ServiceInstance, err error) {
FILE: contrib/registry/etcd/watcher.go
type watcher (line 14) | type watcher struct
method Next (line 44) | func (w *watcher) Next() ([]*registry.ServiceInstance, error) {
method Stop (line 66) | func (w *watcher) Stop() error {
method getInstance (line 71) | func (w *watcher) getInstance() ([]*registry.ServiceInstance, error) {
method reWatch (line 90) | func (w *watcher) reWatch() error {
function newWatcher (line 26) | func newWatcher(ctx context.Context, key, name string, client *clientv3....
FILE: contrib/registry/eureka/client.go
constant statusUp (line 18) | statusUp = "UP"
constant statusDown (line 19) | statusDown = "DOWN"
constant statusOutOfService (line 20) | statusOutOfService = "OUT_OF_SERVICE"
constant heartbeatRetry (line 21) | heartbeatRetry = 3
constant heartbeatTime (line 22) | heartbeatTime = 10 * time.Second
constant httpTimeout (line 23) | httpTimeout = 3 * time.Second
constant refreshTime (line 24) | refreshTime = 30 * time.Second
type Endpoint (line 27) | type Endpoint struct
type ApplicationsRootResponse (line 40) | type ApplicationsRootResponse struct
type ApplicationsResponse (line 44) | type ApplicationsResponse struct
type Application (line 50) | type Application struct
type RequestInstance (line 55) | type RequestInstance struct
type Instance (line 59) | type Instance struct
type Port (line 75) | type Port struct
type DataCenterInfo (line 80) | type DataCenterInfo struct
type APIInterface (line 87) | type APIInterface interface
type ClientOption (line 101) | type ClientOption
function WithMaxRetry (line 103) | func WithMaxRetry(maxRetry int) ClientOption {
function WithHeartbeatInterval (line 107) | func WithHeartbeatInterval(interval time.Duration) ClientOption {
function WithClientContext (line 113) | func WithClientContext(ctx context.Context) ClientOption {
function WithNamespace (line 117) | func WithNamespace(path string) ClientOption {
type Client (line 121) | type Client struct
method FetchApps (line 162) | func (e *Client) FetchApps(ctx context.Context) []Application {
method FetchAppInstances (line 171) | func (e *Client) FetchAppInstances(ctx context.Context, appID string) ...
method FetchAppUpInstances (line 176) | func (e *Client) FetchAppUpInstances(ctx context.Context, appID string...
method FetchAppInstance (line 184) | func (e *Client) FetchAppInstance(ctx context.Context, appID string, i...
method FetchInstance (line 189) | func (e *Client) FetchInstance(ctx context.Context, instanceID string)...
method Out (line 194) | func (e *Client) Out(ctx context.Context, appID, instanceID string) er...
method Down (line 198) | func (e *Client) Down(ctx context.Context, appID, instanceID string) e...
method FetchAllUpInstances (line 202) | func (e *Client) FetchAllUpInstances(ctx context.Context) []Instance {
method Register (line 206) | func (e *Client) Register(ctx context.Context, ep Endpoint) error {
method Deregister (line 210) | func (e *Client) Deregister(ctx context.Context, appID, instanceID str...
method registerEndpoint (line 218) | func (e *Client) registerEndpoint(ctx context.Context, ep Endpoint) er...
method Heartbeat (line 253) | func (e *Client) Heartbeat(ep Endpoint) {
method cancelHeartbeat (line 278) | func (e *Client) cancelHeartbeat(appID string) {
method filterUp (line 286) | func (e *Client) filterUp(apps ...Application) (res []Instance) {
method pickServer (line 298) | func (e *Client) pickServer(currentTimes int) string {
method shuffle (line 302) | func (e *Client) shuffle() {
method buildAPI (line 309) | func (e *Client) buildAPI(currentTimes int, params ...string) string {
method request (line 318) | func (e *Client) request(ctx context.Context, method string, params []...
method do (line 353) | func (e *Client) do(ctx context.Context, method string, params []strin...
function NewClient (line 144) | func NewClient(urls []string, opts ...ClientOption) *Client {
FILE: contrib/registry/eureka/eureka.go
type subscriber (line 10) | type subscriber struct
type API (line 15) | type API struct
method refresh (line 39) | func (e *API) refresh(ctx context.Context) {
method broadcast (line 52) | func (e *API) broadcast() {
method cacheAllInstances (line 66) | func (e *API) cacheAllInstances() map[string][]Instance {
method Register (line 76) | func (e *API) Register(ctx context.Context, serviceName string, endpoi...
method Deregister (line 97) | func (e *API) Deregister(ctx context.Context, endpoints []Endpoint) er...
method Subscribe (line 107) | func (e *API) Subscribe(serverName string, fn func()) error {
method GetService (line 119) | func (e *API) GetService(ctx context.Context, serverName string) []Ins...
method Unsubscribe (line 129) | func (e *API) Unsubscribe(serverName string) {
method ToAppID (line 135) | func (e *API) ToAppID(serverName string) string {
function NewAPI (line 23) | func NewAPI(ctx context.Context, client *Client, refreshInterval time.Du...
FILE: contrib/registry/eureka/register.go
type Option (line 18) | type Option
function WithContext (line 21) | func WithContext(ctx context.Context) Option {
function WithHeartbeat (line 25) | func WithHeartbeat(interval time.Duration) Option {
function WithRefresh (line 29) | func WithRefresh(interval time.Duration) Option {
function WithEurekaPath (line 33) | func WithEurekaPath(path string) Option {
type Registry (line 37) | type Registry struct
method Register (line 68) | func (r *Registry) Register(ctx context.Context, service *registry.Ser...
method Deregister (line 73) | func (r *Registry) Deregister(ctx context.Context, service *registry.S...
method GetService (line 78) | func (r *Registry) GetService(ctx context.Context, serviceName string)...
method Watch (line 95) | func (r *Registry) Watch(ctx context.Context, serviceName string) (reg...
method Endpoints (line 99) | func (r *Registry) Endpoints(service *registry.ServiceInstance) []Endp...
function New (line 45) | func New(eurekaUrls []string, opts ...Option) (*Registry, error) {
FILE: contrib/registry/eureka/register_test.go
function TestRegistry (line 14) | func TestRegistry(_ *testing.T) {
function do (line 38) | func do(r *Registry, s *registry.ServiceInstance) {
function TestLock (line 95) | func TestLock(_ *testing.T) {
FILE: contrib/registry/eureka/watcher.go
type watcher (line 11) | type watcher struct
method Next (line 36) | func (w *watcher) Next() (services []*registry.ServiceInstance, err er...
method Stop (line 56) | func (w *watcher) Stop() error {
function newWatch (line 19) | func newWatch(ctx context.Context, cli *API, serverName string) (*watche...
FILE: contrib/registry/kubernetes/registry.go
constant LabelsKeyServiceID (line 70) | LabelsKeyServiceID = "kratos-service-id"
constant LabelsKeyServiceName (line 72) | LabelsKeyServiceName = "kratos-service-app"
constant LabelsKeyServiceVersion (line 74) | LabelsKeyServiceVersion = "kratos-service-version"
constant AnnotationsKeyMetadata (line 76) | AnnotationsKeyMetadata = "kratos-service-metadata"
constant AnnotationsKeyProtocolMap (line 80) | AnnotationsKeyProtocolMap = "kratos-service-protocols"
type Registry (line 85) | type Registry struct
method Register (line 114) | func (s *Registry) Register(ctx context.Context, service *registry.Ser...
method Deregister (line 158) | func (s *Registry) Deregister(ctx context.Context, _ *registry.Service...
method GetService (line 165) | func (s *Registry) GetService(_ context.Context, name string) ([]*regi...
method sendLatestInstances (line 186) | func (s *Registry) sendLatestInstances(ctx context.Context, name strin...
method Watch (line 195) | func (s *Registry) Watch(ctx context.Context, name string) (registry.W...
method Start (line 228) | func (s *Registry) Start() {
method Close (line 237) | func (s *Registry) Close() {
function NewRegistry (line 95) | func NewRegistry(clientSet *kubernetes.Clientset, namespace string) *Reg...
constant ServiceAccountNamespacePath (line 248) | ServiceAccountNamespacePath = "/var/run/secrets/kubernetes.io/serviceacc...
function LoadNamespace (line 253) | func LoadNamespace() string {
function GetNamespace (line 262) | func GetNamespace() string {
function GetPodName (line 267) | func GetPodName() string {
type protocolMap (line 273) | type protocolMap
method GetProtocol (line 275) | func (m protocolMap) GetProtocol(port int32) string {
type Iterator (line 284) | type Iterator struct
method Next (line 298) | func (iter *Iterator) Next() ([]*registry.ServiceInstance, error) {
method Stop (line 308) | func (iter *Iterator) Stop() error {
function NewIterator (line 290) | func NewIterator(channel chan []*registry.ServiceInstance, stopCh chan s...
function marshal (line 319) | func marshal(in any) (string, error) {
function unmarshal (line 323) | func unmarshal(data string, in any) error {
function isEmptyObjectString (line 327) | func isEmptyObjectString(s string) bool {
function getProtocolMapByEndpoints (line 335) | func getProtocolMapByEndpoints(endpoints []string) (protocolMap, error) {
function getProtocolMapFromPod (line 347) | func getProtocolMapFromPod(pod *corev1.Pod) (protocolMap, error) {
function getMetadataFromPod (line 358) | func getMetadataFromPod(pod *corev1.Pod) (map[string]string, error) {
function getServiceInstanceFromPod (line 369) | func getServiceInstanceFromPod(pod *corev1.Pod) (*registry.ServiceInstan...
type ErrorHandleResource (line 415) | type ErrorHandleResource struct
method Error (line 422) | func (err *ErrorHandleResource) Error() string {
FILE: contrib/registry/kubernetes/registry_test.go
constant namespace (line 22) | namespace = "default"
constant deployName (line 23) | deployName = "hello-deployment"
constant podName (line 24) | podName = "hello"
function getClientSet (line 68) | func getClientSet() (*kubernetes.Clientset, error) {
function int32Ptr (line 86) | func int32Ptr(i int32) *int32 { return &i }
function TestSetEnv (line 88) | func TestSetEnv(t *testing.T) {
function TestRegistry (line 95) | func TestRegistry(t *testing.T) {
FILE: contrib/registry/nacos/registry.go
type options (line 27) | type options struct
type Option (line 36) | type Option
function WithPrefix (line 39) | func WithPrefix(prefix string) Option {
function WithWeight (line 44) | func WithWeight(weight float64) Option {
function WithCluster (line 49) | func WithCluster(cluster string) Option {
function WithGroup (line 54) | func WithGroup(group string) Option {
function WithDefaultKind (line 59) | func WithDefaultKind(kind string) Option {
type Registry (line 64) | type Registry struct
method Register (line 88) | func (r *Registry) Register(_ context.Context, si *registry.ServiceIns...
method Deregister (line 143) | func (r *Registry) Deregister(_ context.Context, service *registry.Ser...
method Watch (line 172) | func (r *Registry) Watch(ctx context.Context, serviceName string) (reg...
method GetService (line 177) | func (r *Registry) GetService(_ context.Context, serviceName string) (...
function New (line 70) | func New(cli naming_client.INamingClient, opts ...Option) (r *Registry) {
FILE: contrib/registry/nacos/registry_test.go
function TestRegistry_Register (line 20) | func TestRegistry_Register(t *testing.T) {
function TestRegistry_Deregister (line 210) | func TestRegistry_Deregister(t *testing.T) {
function TestRegistry_GetService (line 329) | func TestRegistry_GetService(t *testing.T) {
function TestRegistry_Watch (line 443) | func TestRegistry_Watch(t *testing.T) {
FILE: contrib/registry/nacos/watcher.go
type watcher (line 17) | type watcher struct
method Next (line 59) | func (w *watcher) Next() ([]*registry.ServiceInstance, error) {
method Stop (line 90) | func (w *watcher) Stop() error {
function newWatcher (line 29) | func newWatcher(ctx context.Context, cli naming_client.INamingClient, se...
FILE: contrib/registry/polaris/registry.go
constant _instanceIDSeparator (line 26) | _instanceIDSeparator = "-"
type options (line 28) | type options struct
type Option (line 65) | type Option
type Registry (line 68) | type Registry struct
method Register (line 161) | func (r *Registry) Register(_ context.Context, serviceInstance *regist...
method Deregister (line 260) | func (r *Registry) Deregister(_ context.Context, serviceInstance *regi...
method GetService (line 303) | func (r *Registry) GetService(_ context.Context, serviceName string) (...
method Watch (line 323) | func (r *Registry) Watch(ctx context.Context, serviceName string) (reg...
function WithNamespace (line 75) | func WithNamespace(namespace string) Option {
function WithServiceToken (line 80) | func WithServiceToken(serviceToken string) Option {
function WithProtocol (line 85) | func WithProtocol(protocol string) Option {
function WithWeight (line 90) | func WithWeight(weight int) Option {
function WithHealthy (line 95) | func WithHealthy(healthy bool) Option {
function WithIsolate (line 100) | func WithIsolate(isolate bool) Option {
function WithTTL (line 105) | func WithTTL(TTL int) Option {
function WithTimeout (line 110) | func WithTimeout(timeout time.Duration) Option {
function WithRetryCount (line 115) | func WithRetryCount(retryCount int) Option {
function WithHeartbeat (line 120) | func WithHeartbeat(heartbeat bool) Option {
function NewRegistry (line 124) | func NewRegistry(provider api.ProviderAPI, consumer api.ConsumerAPI, opt...
function NewRegistryWithConfig (line 148) | func NewRegistryWithConfig(conf config.Configuration, opts ...Option) (r...
type Watcher (line 327) | type Watcher struct
method Next (line 365) | func (w *Watcher) Next() ([]*registry.ServiceInstance, error) {
method Stop (line 414) | func (w *Watcher) Stop() error {
function newWatcher (line 337) | func newWatcher(ctx context.Context, namespace string, serviceName strin...
function instancesToServiceInstances (line 419) | func instancesToServiceInstances(instances []model.Instance) []*registry...
function instanceToServiceInstance (line 429) | func instanceToServiceInstance(instance model.Instance) *registry.Servic...
FILE: contrib/registry/servicecomb/registry.go
function init (line 18) | func init() {
constant appIDKey (line 38) | appIDKey = "appId"
constant envKey (line 39) | envKey = "environment"
constant envVar (line 40) | envVar = "CAS_ENVIRONMENT_ID"
constant appIDVar (line 41) | appIDVar = "CAS_APPLICATION_NAME"
constant frameWorkName (line 42) | frameWorkName = "kratos"
constant frameWorkVersion (line 43) | frameWorkVersion = "v2"
type RegistryClient (line 46) | type RegistryClient interface
type Registry (line 57) | type Registry struct
method GetService (line 68) | func (r *Registry) GetService(_ context.Context, serviceName string) (...
method Watch (line 86) | func (r *Registry) Watch(ctx context.Context, serviceName string) (reg...
method Register (line 90) | func (r *Registry) Register(_ context.Context, svcIns *registry.Servic...
method Deregister (line 165) | func (r *Registry) Deregister(_ context.Context, svcIns *registry.Serv...
function NewRegistry (line 61) | func NewRegistry(client RegistryClient) *Registry {
FILE: contrib/registry/servicecomb/registry_test.go
function init (line 16) | func init() {
type mockClient (line 20) | type mockClient struct
method WatchMicroService (line 22) | func (receiver *mockClient) WatchMicroService(_ string, _ func(*sc.Mic...
method FindMicroServiceInstances (line 27) | func (receiver *mockClient) FindMicroServiceInstances(_,
method RegisterService (line 36) | func (receiver *mockClient) RegisterService(_ *pb.MicroService) (strin...
method RegisterMicroServiceInstance (line 40) | func (receiver *mockClient) RegisterMicroServiceInstance(_ *pb.MicroSe...
method Heartbeat (line 44) | func (receiver *mockClient) Heartbeat(_, _ string) (bool, error) {
method UnregisterMicroServiceInstance (line 48) | func (receiver *mockClient) UnregisterMicroServiceInstance(_, _ string...
method GetMicroServiceID (line 52) | func (receiver *mockClient) GetMicroServiceID(_, _, _, _ string, _ ......
function TestRegistry (line 56) | func TestRegistry(t *testing.T) {
function TestWatcher (line 94) | func TestWatcher(t *testing.T) {
FILE: contrib/registry/servicecomb/watcher.go
type Watcher (line 13) | type Watcher struct
method Put (line 50) | func (w *Watcher) Put(svcIns *registry.ServiceInstance) {
method Next (line 54) | func (w *Watcher) Next() ([]*registry.ServiceInstance, error) {
method Stop (line 61) | func (w *Watcher) Stop() error {
function newWatcher (line 18) | func newWatcher(_ context.Context, cli RegistryClient, serviceName strin...
FILE: contrib/registry/zookeeper/register.go
type Option (line 21) | type Option
type options (line 23) | type options struct
function WithRootPath (line 30) | func WithRootPath(path string) Option {
function WithDigestACL (line 35) | func WithDigestACL(user string, password string) Option {
type Registry (line 43) | type Registry struct
method Register (line 63) | func (r *Registry) Register(_ context.Context, service *registry.Servi...
method Deregister (line 87) | func (r *Registry) Deregister(ctx context.Context, service *registry.S...
method GetService (line 104) | func (r *Registry) GetService(_ context.Context, serviceName string) (...
method Watch (line 132) | func (r *Registry) Watch(ctx context.Context, serviceName string) (reg...
method ensureName (line 138) | func (r *Registry) ensureName(path string, data []byte, flags int32) e...
method reRegister (line 166) | func (r *Registry) reRegister(path string, data []byte) {
function New (line 50) | func New(conn *zk.Conn, opts ...Option) *Registry {
FILE: contrib/registry/zookeeper/register_test.go
function TestRegistry_GetService (line 14) | func TestRegistry_GetService(t *testing.T) {
function TestRegistry_Register (line 119) | func TestRegistry_Register(t *testing.T) {
function TestRegistry_Deregister (line 215) | func TestRegistry_Deregister(t *testing.T) {
function TestRegistry_Watch (line 286) | func TestRegistry_Watch(t *testing.T) {
FILE: contrib/registry/zookeeper/service.go
function marshal (line 9) | func marshal(si *registry.ServiceInstance) ([]byte, error) {
function unmarshal (line 13) | func unmarshal(data []byte) (si *registry.ServiceInstance, err error) {
FILE: contrib/registry/zookeeper/watcher.go
type watcher (line 18) | type watcher struct
method watch (line 38) | func (w *watcher) watch(ctx context.Context) {
method Next (line 62) | func (w *watcher) Next() ([]*registry.ServiceInstance, error) {
method Stop (line 81) | func (w *watcher) Stop() error {
method getServices (line 86) | func (w *watcher) getServices() ([]*registry.ServiceInstance, error) {
function newWatcher (line 31) | func newWatcher(ctx context.Context, prefix, serviceName string, conn *z...
FILE: contrib/transport/mcp/server.go
type MiddlewareFunc (line 22) | type MiddlewareFunc
type ServerOption (line 25) | type ServerOption
function Address (line 28) | func Address(addr string) ServerOption {
function Endpoint (line 35) | func Endpoint(endpoint *url.URL) ServerOption {
function Middleware (line 42) | func Middleware(m MiddlewareFunc) ServerOption {
function SrvOptions (line 49) | func SrvOptions(opts ...server.ServerOption) ServerOption {
function SSEOptions (line 56) | func SSEOptions(opts ...server.SSEOption) ServerOption {
type Server (line 63) | type Server struct
method ServeHTTP (line 90) | func (s *Server) ServeHTTP(res http.ResponseWriter, req *http.Request) {
method Endpoint (line 97) | func (s *Server) Endpoint() (*url.URL, error) {
method Start (line 105) | func (s *Server) Start(_ context.Context) error {
method Stop (line 115) | func (s *Server) Stop(ctx context.Context) error {
function NewServer (line 75) | func NewServer(name, version string, opts ...ServerOption) *Server {
FILE: contrib/transport/mcp/server_test.go
function TestServer (line 9) | func TestServer(t *testing.T) {
FILE: encoding/encoding.go
type Codec (line 10) | type Codec interface
function RegisterCodec (line 25) | func RegisterCodec(codec Codec) {
function GetCodec (line 40) | func GetCodec(contentSubtype string) Codec {
FILE: encoding/encoding_test.go
type codec (line 9) | type codec struct
method Marshal (line 11) | func (c codec) Marshal(_ any) ([]byte, error) {
method Unmarshal (line 15) | func (c codec) Unmarshal(_ []byte, _ any) error {
method Name (line 19) | func (c codec) Name() string {
type codec2 (line 24) | type codec2 struct
method Marshal (line 26) | func (codec2) Marshal(v any) ([]byte, error) {
method Unmarshal (line 30) | func (codec2) Unmarshal(data []byte, v any) error {
method Name (line 34) | func (codec2) Name() string {
function TestRegisterCodec (line 38) | func TestRegisterCodec(t *testing.T) {
type PanicTestFunc (line 67) | type PanicTestFunc
function didPanic (line 70) | func didPanic(f PanicTestFunc) (bool, any, string) {
FILE: encoding/form/form.go
constant Name (line 15) | Name = "x-www-form-urlencoded"
constant nullStr (line 17) | nullStr = "null"
function init (line 29) | func init() {
type codec (line 35) | type codec struct
method Marshal (line 40) | func (c codec) Marshal(v any) ([]byte, error) {
method Unmarshal (line 62) | func (c codec) Unmarshal(data []byte, v any) error {
method Name (line 85) | func (codec) Name() string {
FILE: encoding/form/form_test.go
function init (line 24) | func init() {
function TestFormEncoderAndDecoder (line 30) | func TestFormEncoderAndDecoder(t *testing.T) {
type LoginRequest (line 82) | type LoginRequest struct
function TestFormCodecMarshal (line 87) | func TestFormCodecMarshal(t *testing.T) {
function TestFormCodecUnmarshal (line 128) | func TestFormCodecUnmarshal(t *testing.T) {
function TestProtoEncodeDecode (line 152) | func TestProtoEncodeDecode(t *testing.T) {
function TestDecodeStructPb (line 232) | func TestDecodeStructPb(t *testing.T) {
function TestDecodeBytesValuePb (line 252) | func TestDecodeBytesValuePb(t *testing.T) {
function TestEncodeFieldMask (line 265) | func TestEncodeFieldMask(t *testing.T) {
function TestOptional (line 274) | func TestOptional(t *testing.T) {
function TestWithUnsupportedType (line 287) | func TestWithUnsupportedType(t *testing.T) {
FILE: encoding/form/proto_decode.go
constant fieldSeparator (line 23) | fieldSeparator = "."
function DecodeValues (line 28) | func DecodeValues(msg proto.Message, values url.Values) error {
function populateFieldValues (line 37) | func populateFieldValues(v protoreflect.Message, fieldPath []string, val...
function getFieldDescriptor (line 84) | func getFieldDescriptor(v protoreflect.Message, fieldName string) protor...
function getDescriptorByFieldAndName (line 109) | func getDescriptorByFieldAndName(fields protoreflect.FieldDescriptors, f...
function populateField (line 117) | func populateField(fd protoreflect.FieldDescriptor, v protoreflect.Messa...
function populateRepeatedField (line 129) | func populateRepeatedField(fd protoreflect.FieldDescriptor, list protore...
function populateMapField (line 140) | func populateMapField(fd protoreflect.FieldDescriptor, mp protoreflect.M...
function parseField (line 157) | func parseField(fd protoreflect.FieldDescriptor, value string) (protoref...
function parseMessage (line 236) | func parseMessage(md protoreflect.MessageDescriptor, value string) (prot...
function jsonSnakeCase (line 336) | func jsonSnakeCase(s string) string {
function isASCIIUpper (line 352) | func isASCIIUpper(c byte) bool {
function parseURLQueryMapKey (line 358) | func parseURLQueryMapKey(key string) (string, string, error) {
FILE: encoding/form/proto_decode_test.go
function TestDecodeValues (line 15) | func TestDecodeValues(t *testing.T) {
function TestGetFieldDescriptor (line 51) | func TestGetFieldDescriptor(t *testing.T) {
function TestPopulateRepeatedField (line 65) | func TestPopulateRepeatedField(t *testing.T) {
function TestPopulateMapField (line 82) | func TestPopulateMapField(t *testing.T) {
function TestPopulateMapSepField (line 100) | func TestPopulateMapSepField(t *testing.T) {
function TestParseField (line 118) | func TestParseField(t *testing.T) {
function TestJsonSnakeCase (line 178) | func TestJsonSnakeCase(t *testing.T) {
function TestIsASCIIUpper (line 206) | func TestIsASCIIUpper(t *testing.T) {
function TestParseURLQueryMapKey (line 237) | func TestParseURLQueryMapKey(t *testing.T) {
function BenchmarkParseURLQueryMapKey (line 306) | func BenchmarkParseURLQueryMapKey(b *testing.B) {
FILE: encoding/form/proto_encode.go
function EncodeValues (line 17) | func EncodeValues(msg any) (url.Values, error) {
function encodeByField (line 29) | func encodeByField(u url.Values, path string, m protoreflect.Message) (f...
function encodeRepeatedField (line 92) | func encodeRepeatedField(fieldDescriptor protoreflect.FieldDescriptor, l...
function encodeMapField (line 104) | func encodeMapField(fieldDescriptor protoreflect.FieldDescriptor, mp pro...
function EncodeField (line 123) | func EncodeField(fieldDescriptor protoreflect.FieldDescriptor, value pro...
function encodeMessage (line 145) | func encodeMessage(msgDescriptor protoreflect.MessageDescriptor, value p...
function EncodeFieldMask (line 173) | func EncodeFieldMask(m protoreflect.Message) (query string) {
function jsonCamelCase (line 197) | func jsonCamelCase(s string) string {
function isASCIILower (line 216) | func isASCIILower(c byte) bool {
FILE: encoding/form/proto_encode_test.go
function TestEncodeValues (line 15) | func TestEncodeValues(t *testing.T) {
function TestJsonCamelCase (line 55) | func TestJsonCamelCase(t *testing.T) {
function TestIsASCIILower (line 83) | func TestIsASCIILower(t *testing.T) {
FILE: encoding/form/well_known_types.go
constant timestampMessageFullname (line 15) | timestampMessageFullname protoreflect.FullName = "google.protobuf....
constant maxTimestampSeconds (line 16) | maxTimestampSeconds = 253402300799
constant minTimestampSeconds (line 17) | minTimestampSeconds = -6213559680013
constant timestampSecondsFieldNumber (line 18) | timestampSecondsFieldNumber protoreflect.FieldNumber = 1
constant timestampNanosFieldNumber (line 19) | timestampNanosFieldNumber protoreflect.FieldNumber = 2
constant durationMessageFullname (line 22) | durationMessageFullname protoreflect.FullName = "google.protobuf.D...
constant secondsInNanos (line 23) | secondsInNanos = 999999999
constant durationSecondsFieldNumber (line 24) | durationSecondsFieldNumber protoreflect.FieldNumber = 1
constant durationNanosFieldNumber (line 25) | durationNanosFieldNumber protoreflect.FieldNumber = 2
constant bytesMessageFullname (line 28) | bytesMessageFullname protoreflect.FullName = "google.protobuf.BytesV...
constant bytesValueFieldNumber (line 29) | bytesValueFieldNumber protoreflect.FieldNumber = 1
constant structMessageFullname (line 32) | structMessageFullname protoreflect.FullName = "google.protobuf.Struct"
constant structFieldsFieldNumber (line 33) | structFieldsFieldNumber protoreflect.FieldNumber = 1
constant fieldMaskFullName (line 35) | fieldMaskFullName protoreflect.FullName = "google.protobuf.FieldMask"
function marshalTimestamp (line 38) | func marshalTimestamp(m protoreflect.Message) (string, error) {
function marshalDuration (line 63) | func marshalDuration(m protoreflect.Message) (string, error) {
function marshalBytes (line 88) | func marshalBytes(m protoreflect.Message) (string, error) {
FILE: encoding/form/well_known_types_test.go
function TestMarshalTimeStamp (line 14) | func TestMarshalTimeStamp(t *testing.T) {
function TestMarshalDuration (line 39) | func TestMarshalDuration(t *testing.T) {
function TestMarshalBytes (line 72) | func TestMarshalBytes(t *testing.T) {
FILE: encoding/json/json.go
constant Name (line 14) | Name = "json"
function init (line 27) | func init() {
type codec (line 32) | type codec struct
method Marshal (line 34) | func (codec) Marshal(v any) ([]byte, error) {
method Unmarshal (line 45) | func (codec) Unmarshal(data []byte, v any) error {
method Name (line 66) | func (codec) Name() string {
FILE: encoding/json/json_test.go
type testEmbed (line 12) | type testEmbed struct
type testMessage (line 18) | type testMessage struct
type mock (line 25) | type mock struct
method UnmarshalJSON (line 35) | func (a *mock) UnmarshalJSON(b []byte) error {
method MarshalJSON (line 52) | func (a *mock) MarshalJSON() ([]byte, error) {
constant Unknown (line 30) | Unknown = iota
constant Gopher (line 31) | Gopher
constant Zebra (line 32) | Zebra
function TestJSON_Marshal (line 66) | func TestJSON_Marshal(t *testing.T) {
function TestJSON_Unmarshal (line 103) | func TestJSON_Unmarshal(t *testing.T) {
FILE: encoding/proto/proto.go
constant Name (line 15) | Name = "proto"
function init (line 17) | func init() {
type codec (line 22) | type codec struct
method Marshal (line 24) | func (codec) Marshal(v any) ([]byte, error) {
method Unmarshal (line 28) | func (codec) Unmarshal(data []byte, v any) error {
method Name (line 36) | func (codec) Name() string {
function getProtoMessage (line 40) | func getProtoMessage(v any) (proto.Message, error) {
FILE: encoding/proto/proto_test.go
function TestName (line 10) | func TestName(t *testing.T) {
function TestCodec (line 17) | func TestCodec(t *testing.T) {
function TestCodec2 (line 48) | func TestCodec2(t *testing.T) {
function Test_getProtoMessage (line 80) | func Test_getProtoMessage(t *testing.T) {
FILE: encoding/xml/xml.go
constant Name (line 10) | Name = "xml"
function init (line 12) | func init() {
type codec (line 17) | type codec struct
method Marshal (line 19) | func (codec) Marshal(v any) ([]byte, error) {
method Unmarshal (line 23) | func (codec) Unmarshal(data []byte, v any) error {
method Name (line 27) | func (codec) Name() string {
FILE: encoding/xml/xml_test.go
type Plain (line 9) | type Plain struct
type NestedOrder (line 13) | type NestedOrder struct
function TestCodec_Marshal (line 20) | func TestCodec_Marshal(t *testing.T) {
function TestCodec_Unmarshal (line 55) | func TestCodec_Unmarshal(t *testing.T) {
function TestCodec_NilUnmarshal (line 86) | func TestCodec_NilUnmarshal(t *testing.T) {
FILE: encoding/yaml/yaml.go
constant Name (line 10) | Name = "yaml"
function init (line 12) | func init() {
type codec (line 17) | type codec struct
method Marshal (line 19) | func (codec) Marshal(v any) ([]byte, error) {
method Unmarshal (line 23) | func (codec) Unmarshal(data []byte, v any) error {
method Name (line 27) | func (codec) Name() string {
FILE: encoding/yaml/yaml_test.go
function TestCodec_Unmarshal (line 9) | func TestCodec_Unmarshal(t *testing.T) {
function TestCodec_Marshal (line 95) | func TestCodec_Marshal(t *testing.T) {
FILE: errors/errors.go
constant UnknownCode (line 15) | UnknownCode = 500
constant UnknownReason (line 17) | UnknownReason = ""
constant SupportPackageIsVersion1 (line 19) | SupportPackageIsVersion1 = true
type Error (line 23) | type Error struct
method Error (line 28) | func (e *Error) Error() string {
method Unwrap (line 33) | func (e *Error) Unwrap() error { return e.cause }
method Is (line 36) | func (e *Error) Is(err error) bool {
method WithCause (line 44) | func (e *Error) WithCause(cause error) *Error {
method WithMetadata (line 51) | func (e *Error) WithMetadata(md map[string]string) *Error {
method GRPCStatus (line 58) | func (e *Error) GRPCStatus() *status.Status {
function New (line 68) | func New(code int, reason, message string) *Error {
function Newf (line 79) | func Newf(code int, reason, format string, a ...any) *Error {
function Errorf (line 84) | func Errorf(code int, reason, format string, a ...any) error {
function Code (line 90) | func Code(err error) int {
function Reason (line 99) | func Reason(err error) string {
function Clone (line 107) | func Clone(err *Error) *Error {
function FromError (line 128) | func FromError(err error) *Error {
FILE: errors/errors.pb.go
constant _ (line 19) | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
constant _ (line 21) | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
type Status (line 24) | type Status struct
method Reset (line 35) | func (x *Status) Reset() {
method String (line 44) | func (x *Status) String() string {
method ProtoMessage (line 48) | func (*Status) ProtoMessage() {}
method ProtoReflect (line 50) | func (x *Status) ProtoReflect() protoreflect.Message {
method Descriptor (line 63) | func (*Status) Descriptor() ([]byte, []int) {
method GetCode (line 67) | func (x *Status) GetCode() int32 {
method GetReason (line 74) | func (x *Status) GetReason() string {
method GetMessage (line 81) | func (x *Status) GetMessage() string {
method GetMetadata (line 88) | func (x *Status) GetMetadata() map[string]string {
function file_errors_errors_proto_rawDescGZIP (line 167) | func file_errors_errors_proto_rawDescGZIP() []byte {
function init (line 192) | func init() { file_errors_errors_proto_init() }
function file_errors_errors_proto_init (line 193) | func file_errors_errors_proto_init() {
FILE: errors/errors_test.go
type TestError (line 14) | type TestError struct
method Error (line 16) | func (e *TestError) Error() string { return e.message }
function TestErrors (line 18) | func TestErrors(t *testing.T) {
function TestIs (line 73) | func TestIs(t *testing.T) {
function TestCause (line 102) | func TestCause(t *testing.T) {
function TestOther (line 115) | func TestOther(t *testing.T) {
FILE: errors/types.go
function BadRequest (line 5) | func BadRequest(reason, message string) *Error {
function IsBadRequest (line 11) | func IsBadRequest(err error) bool {
function Unauthorized (line 16) | func Unauthorized(reason, message string) *Error {
function IsUnauthorized (line 22) | func IsUnauthorized(err error) bool {
function Forbidden (line 27) | func Forbidden(reason, message string) *Error {
function IsForbidden (line 33) | func IsForbidden(err error) bool {
function NotFound (line 38) | func NotFound(reason, message string) *Error {
function IsNotFound (line 44) | func IsNotFound(err error) bool {
function Conflict (line 49) | func Conflict(reason, message string) *Error {
function IsConflict (line 55) | func IsConflict(err error) bool {
function TooManyRequests (line 60) | func TooManyRequests(reason, message string) *Error {
function IsTooManyRequests (line 66) | func IsTooManyRequests(err error) bool {
function ClientClosed (line 71) | func ClientClosed(reason, message string) *Error {
function IsClientClosed (line 77) | func IsClientClosed(err error) bool {
function InternalServer (line 82) | func InternalServer(reason, message string) *Error {
function IsInternalServer (line 88) | func IsInternalServer(err error) bool {
function ServiceUnavailable (line 93) | func ServiceUnavailable(reason, message string) *Error {
function IsServiceUnavailable (line 99) | func IsServiceUnavailable(err error) bool {
function GatewayTimeout (line 104) | func GatewayTimeout(reason, message string) *Error {
function IsGatewayTimeout (line 110) | func IsGatewayTimeout(err error) bool {
FILE: errors/types_test.go
function TestTypes (line 7) | func TestTypes(t *testing.T) {
FILE: errors/wrap.go
function Is (line 14) | func Is(err, target error) bool { return stderrors.Is(err, target) }
function As (line 29) | func As(err error, target any) bool { return stderrors.As(err, target) }
function Unwrap (line 34) | func Unwrap(err error) error {
FILE: errors/wrap_test.go
type mockErr (line 8) | type mockErr struct
method Error (line 10) | func (*mockErr) Error() string {
function TestWarp (line 14) | func TestWarp(t *testing.T) {
FILE: internal/context/context.go
type mergeCtx (line 10) | type mergeCtx struct
method finish (line 41) | func (mc *mergeCtx) finish(err error) error {
method wait (line 50) | func (mc *mergeCtx) wait() {
method cancel (line 63) | func (mc *mergeCtx) cancel() {
method Done (line 70) | func (mc *mergeCtx) Done() <-chan struct{} {
method Err (line 75) | func (mc *mergeCtx) Err() error {
method Deadline (line 94) | func (mc *mergeCtx) Deadline() (time.Time, bool) {
method Value (line 110) | func (mc *mergeCtx) Value(key any) any {
function Merge (line 23) | func Merge(parent1, parent2 context.Context) (context.Context, context.C...
FILE: internal/context/context_test.go
function TestContext (line 11) | func TestContext(t *testing.T) {
function TestMerge (line 42) | func TestMerge(t *testing.T) {
function TestErr (line 74) | func TestErr(t *testing.T) {
function TestDone (line 86) | func TestDone(t *testing.T) {
function TestFinish (line 101) | func TestFinish(t *testing.T) {
function TestWait (line 120) | func TestWait(t *testing.T) {
function TestCancel (line 160) | func TestCancel(t *testing.T) {
function Test_mergeCtx_Deadline (line 173) | func Test_mergeCtx_Deadline(t *testing.T) {
function Test_Err2 (line 239) | func Test_Err2(t *testing.T) {
FILE: internal/endpoint/endpoint.go
function NewEndpoint (line 8) | func NewEndpoint(scheme, host string) *url.URL {
function ParseEndpoint (line 13) | func ParseEndpoint(endpoints []string, scheme string) (string, error) {
function Scheme (line 29) | func Scheme(scheme string, isSecure bool) string {
FILE: internal/endpoint/endpoint_test.go
function TestNewEndpoint (line 9) | func TestNewEndpoint(t *testing.T) {
function TestParseEndpoint (line 44) | func TestParseEndpoint(t *testing.T) {
function TestSchema (line 94) | func TestSchema(t *testing.T) {
FILE: internal/group/example_test.go
type Counter (line 5) | type Counter struct
method Incr (line 9) | func (c *Counter) Incr() {
function ExampleGroup_Get (line 13) | func ExampleGroup_Get() {
function ExampleGroup_Reset (line 28) | func ExampleGroup_Reset() {
FILE: internal/group/group.go
type Factory (line 9) | type Factory
type Group (line 12) | type Group struct
function NewGroup (line 19) | func NewGroup[T any](factory Factory[T]) *Group[T] {
method Get (line 30) | func (g *Group[T]) Get(key string) T {
method Reset (line 52) | func (g *Group[T]) Reset(factory Factory[T]) {
method Clear (line 63) | func (g *Group[T]) Clear() {
FILE: internal/group/group_test.go
function TestGroupGet (line 8) | func TestGroupGet(t *testing.T) {
function TestGroupReset (line 33) | func TestGroupReset(t *testing.T) {
function TestGroupClear (line 58) | func TestGroupClear(t *testing.T) {
FILE: internal/host/host.go
function ExtractHostPort (line 10) | func ExtractHostPort(addr string) (host string, port uint64, err error) {
function isValidIP (line 20) | func isValidIP(addr string) bool {
function Port (line 26) | func Port(lis net.Listener) (int, bool) {
function Extract (line 34) | func Extract(hostPort string, lis net.Listener) (string, error) {
FILE: internal/host/host_test.go
function TestValidIP (line 9) | func TestValidIP(t *testing.T) {
function TestExtract (line 54) | func TestExtract(t *testing.T) {
function TestExtract2 (line 95) | func TestExtract2(t *testing.T) {
function TestPort (line 110) | func TestPort(t *testing.T) {
function TestExtractHostPort (line 121) | func TestExtractHostPort(t *testing.T) {
function TestIpIsUp (line 141) | func TestIpIsUp(t *testing.T) {
FILE: internal/httputil/http.go
constant baseContentType (line 8) | baseContentType = "application"
function ContentType (line 12) | func ContentType(subtype string) string {
function ContentSubtype (line 21) | func ContentSubtype(contentType string) string {
FILE: internal/httputil/http_test.go
function TestContentSubtype (line 7) | func TestContentSubtype(t *testing.T) {
function TestContentType (line 31) | func TestContentType(t *testing.T) {
FILE: internal/matcher/middleware.go
type Matcher (line 11) | type Matcher interface
function New (line 18) | func New() Matcher {
type matcher (line 24) | type matcher struct
method Use (line 30) | func (m *matcher) Use(ms ...middleware.Middleware) {
method Add (line 34) | func (m *matcher) Add(selector string, ms ...middleware.Middleware) {
method Match (line 48) | func (m *matcher) Match(operation string) []middleware.Middleware {
FILE: internal/matcher/middleware_test.go
function logging (line 10) | func logging(module string) middleware.Middleware {
function equal (line 18) | func equal(ms []middleware.Middleware, modules ...string) bool {
function TestMatcher (line 31) | func TestMatcher(t *testing.T) {
FILE: internal/testdata/binding/test.pb.go
constant _ (line 19) | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
constant _ (line 21) | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
type HelloRequest (line 25) | type HelloRequest struct
method Reset (line 40) | func (x *HelloRequest) Reset() {
method String (line 49) | func (x *HelloRequest) String() string {
method ProtoMessage (line 53) | func (*HelloRequest) ProtoMessage() {}
method ProtoReflect (line 55) | func (x *HelloRequest) ProtoReflect() protoreflect.Message {
method Descriptor (line 68) | func (*HelloRequest) Descriptor() ([]byte, []int) {
method GetName (line 72) | func (x *HelloRequest) GetName() string {
method GetSub (line 79) | func (x *HelloRequest) GetSub() *Sub {
method GetUpdateMask (line 86) | func (x *HelloRequest) GetUpdateMask() *fieldmaskpb.FieldMask {
method GetOptInt32 (line 93) | func (x *HelloRequest) GetOptInt32() int32 {
method GetOptInt64 (line 100) | func (x *HelloRequest) GetOptInt64() int64 {
method GetOptString (line 107) | func (x *HelloRequest) GetOptString() string {
method GetSubField (line 114) | func (x *HelloRequest) GetSubField() *Sub {
method GetTestRepeated (line 121) | func (x *HelloRequest) GetTestRepeated() []string {
type Sub (line 128) | type Sub struct
method Reset (line 136) | func (x *Sub) Reset() {
method String (line 145) | func (x *Sub) String() string {
method ProtoMessage (line 149) | func (*Sub) ProtoMessage() {}
method ProtoReflect (line 151) | func (x *Sub) ProtoReflect() protoreflect.Message {
method Descriptor (line 164) | func (*Sub) Descriptor() ([]byte, []int) {
method GetName (line 168) | func (x *Sub) GetName() string {
function file_test_proto_rawDescGZIP (line 217) | func file_test_proto_rawDescGZIP() []byte {
function init (line 241) | func init() { file_test_proto_init() }
function file_test_proto_init (line 242) | func file_test_proto_init() {
FILE: internal/testdata/complex/complex.pb.go
constant _ (line 22) | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
constant _ (line 24) | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
type Sex (line 27) | type Sex
method Enum (line 46) | func (x Sex) Enum() *Sex {
method String (line 52) | func (x Sex) String() string {
method Descriptor (line 56) | func (Sex) Descriptor() protoreflect.EnumDescriptor {
method Type (line 60) | func (Sex) Type() protoreflect.EnumType {
method Number (line 64) | func (x Sex) Number() protoreflect.EnumNumber {
method EnumDescriptor (line 69) | func (Sex) EnumDescriptor() ([]byte, []int) {
constant Sex_man (line 30) | Sex_man Sex = 0
constant Sex_woman (line 31) | Sex_woman Sex = 1
type Complex (line 74) | type Complex struct
method Reset (line 109) | func (x *Complex) Reset() {
method String (line 118) | func (x *Complex) String() string {
method ProtoMessage (line 122) | func (*Complex) ProtoMessage() {}
method ProtoReflect (line 124) | func (x *Complex) ProtoReflect() protoreflect.Message {
method Descriptor (line 137) | func (*Complex) Descriptor() ([]byte, []int) {
method GetId (line 141) | func (x *Complex) GetId() int64 {
method GetNoOne (line 148) | func (x *Complex) GetNoOne() string {
method GetSimple (line 155) | func (x *Complex) GetSimple() *Simple {
method GetStrings (line 162) | func (x *Complex) GetStrings() []string {
method GetSimples (line 169) | func (x *Complex) GetSimples() []*Simple {
method GetB (line 176) | func (x *Complex) GetB() bool {
method GetSex (line 183) | func (x *Complex) GetSex() Sex {
method GetAge (line 190) | func (x *Complex) GetAge() int32 {
method GetA (line 197) | func (x *Complex) GetA() uint32 {
method GetCount (line 204) | func (x *Complex) GetCount() uint64 {
method GetPrice (line 211) | func (x *Complex) GetPrice() float32 {
method GetD (line 218) | func (x *Complex) GetD() float64 {
method GetByte (line 225) | func (x *Complex) GetByte() []byte {
method GetTimestamp (line 232) | func (x *Complex) GetTimestamp() *timestamppb.Timestamp {
method GetDuration (line 239) | func (x *Complex) GetDuration() *durationpb.Duration {
method GetField (line 246) | func (x *Complex) GetField() *fieldmaskpb.FieldMask {
method GetDouble (line 253) | func (x *Complex) GetDouble() *wrapperspb.DoubleValue {
method GetFloat (line 260) | func (x *Complex) GetFloat() *wrapperspb.FloatValue {
method GetInt64 (line 267) | func (x *Complex) GetInt64() *wrapperspb.Int64Value {
method GetInt32 (line 274) | func (x *Complex) GetInt32() *wrapperspb.Int32Value {
method GetUint64 (line 281) | func (x *Complex) GetUint64() *wrapperspb.UInt64Value {
method GetUint32 (line 288) | func (x *Complex) GetUint32() *wrapperspb.UInt32Value {
method GetBool (line 295) | func (x *Complex) GetBool() *wrapperspb.BoolValue {
method GetString_ (line 302) | func (x *Complex) GetString_() *wrapperspb.StringValue {
method GetBytes (line 309) | func (x *Complex) GetBytes() *wrapperspb.BytesValue {
method GetMap (line 316) | func (x *Complex) GetMap() map[string]string {
method GetMapInt64Key (line 323) | func (x *Complex) GetMapInt64Key() map[int64]string {
type Simple (line 330) | type Simple struct
method Reset (line 338) | func (x *Simple) Reset() {
method String (line 347) | func (x *Simple) String() string {
method ProtoMessage (line 351) | func (*Simple) ProtoMessage() {}
method ProtoReflect (line 353) | func (x *Simple) ProtoReflect() protoreflect.Message {
method Descriptor (line 366) | func (*Simple) Descriptor() ([]byte, []int) {
method GetComponent (line 370) | func (x *Simple) GetComponent() string {
function file_complex_proto_rawDescGZIP (line 483) | func file_complex_proto_rawDescGZIP() []byte {
function init (line 536) | func init() { file_complex_proto_init() }
function file_complex_proto_init (line 537) | func file_complex_proto_init() {
FILE: internal/testdata/encoding/test.pb.go
constant _ (line 19) | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
constant _ (line 21) | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
type TestModel (line 24) | type TestModel struct
method Reset (line 35) | func (x *TestModel) Reset() {
method String (line 44) | func (x *TestModel) String() string {
method ProtoMessage (line 48) | func (*TestModel) ProtoMessage() {}
method ProtoReflect (line 50) | func (x *TestModel) ProtoReflect() protoreflect.Message {
method Descriptor (line 63) | func (*TestModel) Descriptor() ([]byte, []int) {
method GetId (line 67) | func (x *TestModel) GetId() int64 {
method GetName (line 74) | func (x *TestModel) GetName() string {
method GetHobby (line 81) | func (x *TestModel) GetHobby() []string {
method GetAttrs (line 88) | func (x *TestModel) GetAttrs() map[string]string {
type StructPb (line 95) | type StructPb struct
method Reset (line 104) | func (x *StructPb) Reset() {
method String (line 113) | func (x *StructPb) String() string {
method ProtoMessage (line 117) | func (*StructPb) ProtoMessage() {}
method ProtoReflect (line 119) | func (x *StructPb) ProtoReflect() protoreflect.Message {
method Descriptor (line 132) | func (*StructPb) Descriptor() ([]byte, []int) {
method GetData (line 136) | func (x *StructPb) GetData() *structpb.Struct {
method GetDataList (line 143) | func (x *StructPb) GetDataList() []*structpb.Struct {
function file_encoding_test_proto_rawDescGZIP (line 184) | func file_encoding_test_proto_rawDescGZIP() []byte {
function init (line 209) | func init() { file_encoding_test_proto_init() }
function file_encoding_test_proto_init (line 210) | func file_encoding_test_proto_init() {
FILE: internal/testdata/helloworld/helloworld.pb.go
constant _ (line 19) | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
constant _ (line 21) | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
type HelloRequest (line 25) | type HelloRequest struct
method Reset (line 33) | func (x *HelloRequest) Reset() {
method String (line 42) | func (x *HelloRequest) String() string {
method ProtoMessage (line 46) | func (*HelloRequest) ProtoMessage() {}
method ProtoReflect (line 48) | func (x *HelloRequest) ProtoReflect() protoreflect.Message {
method Descriptor (line 61) | func (*HelloRequest) Descriptor() ([]byte, []int) {
method GetName (line 65) | func (x *HelloRequest) GetName() string {
type HelloReply (line 73) | type HelloReply struct
method Reset (line 81) | func (x *HelloReply) Reset() {
method String (line 90) | func (x *HelloReply) String() string {
method ProtoMessage (line 94) | func (*HelloReply) ProtoMessage() {}
method ProtoReflect (line 96) | func (x *HelloReply) ProtoReflect() protoreflect.Message {
method Descriptor (line 109) | func (*HelloReply) Descriptor() ([]byte, []int) {
method GetMessage (line 113) | func (x *HelloReply) GetMessage() string {
function file_helloworld_proto_rawDescGZIP (line 154) | func file_helloworld_proto_rawDescGZIP() []byte {
function init (line 178) | func init() { file_helloworld_proto_init() }
function file_helloworld_proto_init (line 179) | func file_helloworld_proto_init() {
FILE: internal/testdata/helloworld/helloworld_grpc.pb.go
constant _ (line 19) | _ = grpc.SupportPackageIsVersion7
type GreeterClient (line 24) | type GreeterClient interface
type greeterClient (line 31) | type greeterClient struct
method SayHello (line 39) | func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest...
method SayHelloStream (line 48) | func (c *greeterClient) SayHelloStream(ctx context.Context, opts ...gr...
function NewGreeterClient (line 35) | func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient {
type Greeter_SayHelloStreamClient (line 57) | type Greeter_SayHelloStreamClient interface
type greeterSayHelloStreamClient (line 63) | type greeterSayHelloStreamClient struct
method Send (line 67) | func (x *greeterSayHelloStreamClient) Send(m *HelloRequest) error {
method Recv (line 71) | func (x *greeterSayHelloStreamClient) Recv() (*HelloReply, error) {
type GreeterServer (line 82) | type GreeterServer interface
type UnimplementedGreeterServer (line 91) | type UnimplementedGreeterServer struct
method SayHello (line 94) | func (UnimplementedGreeterServer) SayHello(context.Context, *HelloRequ...
method SayHelloStream (line 97) | func (UnimplementedGreeterServer) SayHelloStream(Greeter_SayHelloStrea...
method mustEmbedUnimplementedGreeterServer (line 100) | func (UnimplementedGreeterServer) mustEmbedUnimplementedGreeterServer(...
type UnsafeGreeterServer (line 105) | type UnsafeGreeterServer interface
function RegisterGreeterServer (line 109) | func RegisterGreeterServer(s grpc.ServiceRegistrar, srv GreeterServer) {
function _Greeter_SayHello_Handler (line 113) | func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec...
function _Greeter_SayHelloStream_Handler (line 131) | func _Greeter_SayHelloStream_Handler(srv interface{}, stream grpc.Server...
type Greeter_SayHelloStreamServer (line 135) | type Greeter_SayHelloStreamServer interface
type greeterSayHelloStreamServer (line 141) | type greeterSayHelloStreamServer struct
method Send (line 145) | func (x *greeterSayHelloStreamServer) Send(m *HelloReply) error {
method Recv (line 149) | func (x *greeterSayHelloStreamServer) Recv() (*HelloRequest, error) {
FILE: internal/testdata/helloworld/helloworld_http.pb.go
constant _ (line 18) | _ = http.SupportPackageIsVersion1
constant OperationGreeterSayHello (line 20) | OperationGreeterSayHello = "/helloworld.Greeter/SayHello"
type GreeterHTTPServer (line 22) | type GreeterHTTPServer interface
function RegisterGreeterHTTPServer (line 26) | func RegisterGreeterHTTPServer(s *http.Server, srv GreeterHTTPServer) {
function _Greeter_SayHello0_HTTP_Handler (line 31) | func _Greeter_SayHello0_HTTP_Handler(srv GreeterHTTPServer) func(ctx htt...
type GreeterHTTPClient (line 53) | type GreeterHTTPClient interface
type GreeterHTTPClientImpl (line 57) | type GreeterHTTPClientImpl struct
method SayHello (line 65) | func (c *GreeterHTTPClientImpl) SayHello(ctx context.Context, in *Hell...
function NewGreeterHTTPClient (line 61) | func NewGreeterHTTPClient(client *http.Client) GreeterHTTPClient {
FILE: log/filter.go
type FilterOption (line 4) | type FilterOption
constant fuzzyStr (line 6) | fuzzyStr = "***"
function FilterLevel (line 9) | func FilterLevel(level Level) FilterOption {
function FilterKey (line 16) | func FilterKey(key ...string) FilterOption {
function FilterValue (line 25) | func FilterValue(value ...string) FilterOption {
function FilterFunc (line 34) | func FilterFunc(f func(level Level, keyvals ...any) bool) FilterOption {
type Filter (line 41) | type Filter struct
method Log (line 63) | func (f *Filter) Log(level Level, keyvals ...any) error {
function NewFilter (line 50) | func NewFilter(logger Logger, opts ...FilterOption) *Filter {
FILE: log/filter_test.go
function TestFilterAll (line 13) | func TestFilterAll(_ *testing.T) {
function TestFilterLevel (line 28) | func TestFilterLevel(_ *testing.T) {
function TestFilterCaller (line 38) | func TestFilterCaller(_ *testing.T) {
function TestFilterKey (line 46) | func TestFilterKey(_ *testing.T) {
function TestFilterValue (line 52) | func TestFilterValue(_ *testing.T) {
function TestFilterFunc (line 58) | func TestFilterFunc(_ *testing.T) {
function BenchmarkFilterKey (line 65) | func BenchmarkFilterKey(b *testing.B) {
function BenchmarkFilterValue (line 72) | func BenchmarkFilterValue(b *testing.B) {
function BenchmarkFilterFunc (line 79) | func BenchmarkFilterFunc(b *testing.B) {
function testFilterFunc (line 86) | func testFilterFunc(level Level, keyvals ...any) bool {
function TestFilterFuncWitchLoggerPrefix (line 98) | func TestFilterFuncWitchLoggerPrefix(t *testing.T) {
function testFilterFuncWithLoggerPrefix (line 133) | func testFilterFuncWithLoggerPrefix(level Level, keyvals ...any) bool {
function TestFilterWithContext (line 148) | func TestFilterWithContext(t *testing.T) {
type traceIDKey (line 181) | type traceIDKey struct
function setTraceID (line 183) | func setTraceID(ctx context.Context, tid string) context.Context {
function traceIDValuer (line 187) | func traceIDValuer() Valuer {
function TestFilterWithContextConcurrent (line 199) | func TestFilterWithContextConcurrent(t *testing.T) {
FILE: log/global.go
type loggerAppliance (line 15) | type loggerAppliance struct
method SetLogger (line 24) | func (a *loggerAppliance) SetLogger(in Logger) {
function init (line 20) | func init() {
function SetLogger (line 32) | func SetLogger(logger Logger) {
function GetLogger (line 37) | func GetLogger() Logger {
function Log (line 44) | func Log(level Level, keyvals ...any) {
function Context (line 49) | func Context(ctx context.Context) *Helper {
function Debug (line 54) | func Debug(a ...any) {
function Debugf (line 59) | func Debugf(format string, a ...any) {
function Debugw (line 64) | func Debugw(keyvals ...any) {
function Info (line 69) | func Info(a ...any) {
function Infof (line 74) | func Infof(format string, a ...any) {
function Infow (line 79) | func Infow(keyvals ...any) {
function Warn (line 84) | func Warn(a ...any) {
function Warnf (line 89) | func Warnf(format string, a ...any) {
function Warnw (line 94) | func Warnw(keyvals ...any) {
function Error (line 99) | func Error(a ...any) {
function Errorf (line 104) | func Errorf(format string, a ...any) {
function Errorw (line 109) | func Errorw(keyvals ...any) {
function Fatal (line 114) | func Fatal(a ...any) {
function Fatalf (line 120) | func Fatalf(format string, a ...any) {
function Fatalw (line 126) | func Fatalw(keyvals ...any) {
FILE: log/global_test.go
function TestGlobalLog (line 12) | func TestGlobalLog(t *testing.T) {
function TestGlobalLogUpdate (line 96) | func TestGlobalLogUpdate(t *testing.T) {
function TestGlobalContext (line 112) | func TestGlobalContext(t *testing.T) {
function TestContextWithGlobalLog (line 121) | func TestContextWithGlobalLog(t *testing.T) {
FILE: log/helper.go
type Option (line 13) | type Option
type Helper (line 16) | type Helper struct
method WithContext (line 60) | func (h *Helper) WithContext(ctx context.Context) *Helper {
method Enabled (line 71) | func (h *Helper) Enabled(level Level) bool {
method Logger (line 79) | func (h *Helper) Logger() Logger {
method Log (line 84) | func (h *Helper) Log(level Level, keyvals ...any) {
method Debug (line 89) | func (h *Helper) Debug(a ...any) {
method Debugf (line 97) | func (h *Helper) Debugf(format string, a ...any) {
method Debugw (line 105) | func (h *Helper) Debugw(keyvals ...any) {
method Info (line 110) | func (h *Helper) Info(a ...any) {
method Infof (line 118) | func (h *Helper) Infof(format string, a ...any) {
method Infow (line 126) | func (h *Helper) Infow(keyvals ...any) {
method Warn (line 131) | func (h *Helper) Warn(a ...any) {
method Warnf (line 139) | func (h *Helper) Warnf(format string, a ...any) {
method Warnw (line 147) | func (h *Helper) Warnw(keyvals ...any) {
method Error (line 152) | func (h *Helper) Error(a ...any) {
method Errorf (line 160) | func (h *Helper) Errorf(format string, a ...any) {
method Errorw (line 168) | func (h *Helper) Errorw(keyvals ...any) {
method Fatal (line 173) | func (h *Helper) Fatal(a ...any) {
method Fatalf (line 179) | func (h *Helper) Fatalf(format string, a ...any) {
method Fatalw (line 185) | func (h *Helper) Fatalw(keyvals ...any) {
function WithMessageKey (line 24) | func WithMessageKey(k string) Option {
function WithSprint (line 31) | func WithSprint(sprint func(...any) string) Option {
function WithSprintf (line 38) | func WithSprintf(sprintf func(format string, a ...any) string) Option {
function NewHelper (line 45) | func NewHelper(logger Logger, opts ...Option) *Helper {
FILE: log/helper_test.go
function TestHelper (line 10) | func TestHelper(_ *testing.T) {
function TestHelperWithMsgKey (line 35) | func TestHelperWithMsgKey(_ *testing.T) {
function TestHelperLevel (line 42) | func TestHelperLevel(_ *testing.T) {
function BenchmarkHelperPrint (line 53) | func BenchmarkHelperPrint(b *testing.B) {
function BenchmarkHelperPrintFilterLevel (line 60) | func BenchmarkHelperPrintFilterLevel(b *testing.B) {
function BenchmarkHelperPrintf (line 67) | func BenchmarkHelperPrintf(b *testing.B) {
function BenchmarkHelperPrintfFilterLevel (line 74) | func BenchmarkHelperPrintfFilterLevel(b *testing.B) {
function BenchmarkHelperPrintw (line 81) | func BenchmarkHelperPrintw(b *testing.B) {
type traceKey (line 88) | type traceKey struct
function TestContext (line 90) | func TestContext(_ *testing.T) {
function Trace (line 99) | func Trace() Valuer {
FILE: log/helper_writer.go
type writerWrapper (line 5) | type writerWrapper struct
method Write (line 38) | func (ww *writerWrapper) Write(p []byte) (int, error) {
type WriterOptionFn (line 10) | type WriterOptionFn
function WithWriterLevel (line 13) | func WithWriterLevel(level Level) WriterOptionFn {
function WithWriteMessageKey (line 20) | func WithWriteMessageKey(key string) WriterOptionFn {
function NewWriter (line 27) | func NewWriter(logger Logger, opts ...WriterOptionFn) io.Writer {
FILE: log/helper_writer_test.go
function TestWriterWrapper (line 10) | func TestWriterWrapper(t *testing.T) {
FILE: log/level.go
type Level (line 6) | type Level
method Key (line 24) | func (l Level) Key() string {
method String (line 28) | func (l Level) String() string {
constant LevelKey (line 9) | LevelKey = "level"
constant LevelDebug (line 13) | LevelDebug Level = iota - 1
constant LevelInfo (line 15) | LevelInfo
constant LevelWarn (line 17) | LevelWarn
constant LevelError (line 19) | LevelError
constant LevelFatal (line 21) | LevelFatal
function ParseLevel (line 46) | func ParseLevel(s string) Level {
FILE: log/level_test.go
function TestLevel_Key (line 5) | func TestLevel_Key(t *testing.T) {
function TestLevel_String (line 11) | func TestLevel_String(t *testing.T) {
function TestParseLevel (line 57) | func TestParseLevel(t *testing.T) {
FILE: log/log.go
type Logger (line 12) | type Logger interface
type logger (line 16) | type logger struct
method Log (line 23) | func (c *logger) Log(level Level, keyvals ...any) error {
function With (line 34) | func With(l Logger, kv ...any) Logger {
function WithContext (line 52) | func WithContext(ctx context.Context, l Logger) Logger {
FILE: log/log_test.go
function TestInfo (line 7) | func TestInfo(_ *testing.T) {
FILE: log/std.go
type stdLogger (line 14) | type stdLogger struct
method Log (line 35) | func (l *stdLogger) Log(level Level, keyvals ...any) error {
method Close (line 59) | func (l *stdLogger) Close() error {
function NewStdLogger (line 22) | func NewStdLogger(w io.Writer) Logger {
FILE: log/std_test.go
function TestStdLogger (line 10) | func TestStdLogger(_ *testing.T) {
function TestStdLogger_Log (line 24) | func TestStdLogger_Log(t *testing.T) {
FILE: log/value.go
type Valuer (line 20) | type Valuer
function Value (line 23) | func Value(ctx context.Context, v any) any {
function Caller (line 31) | func Caller(depth int) Valuer {
function Timestamp (line 44) | func Timestamp(layout string) Valuer {
function bindValues (line 50) | func bindValues(ctx context.Context, keyvals []any) {
function containsValuer (line 58) | func containsValuer(keyvals []any) bool {
FILE: log/value_test.go
function TestValue (line 8) | func TestValue(t *testing.T) {
FILE: metadata/metadata.go
type Metadata (line 13) | type Metadata
method Add (line 29) | func (m Metadata) Add(key, value string) {
method Get (line 39) | func (m Metadata) Get(key string) string {
method Set (line 48) | func (m Metadata) Set(key string, value string) {
method Range (line 56) | func (m Metadata) Range(f func(k string, v []string) bool) {
method Values (line 65) | func (m Metadata) Values(key string) []string {
method Clone (line 70) | func (m Metadata) Clone() Metadata {
function New (line 16) | func New(mds ...map[string][]string) Metadata {
type serverMetadataKey (line 78) | type serverMetadataKey struct
function NewServerContext (line 81) | func NewServerContext(ctx context.Context, md Metadata) context.Context {
function FromServerContext (line 86) | func FromServerContext(ctx context.Context) (Metadata, bool) {
type clientMetadataKey (line 91) | type clientMetadataKey struct
function NewClientContext (line 94) | func NewClientContext(ctx context.Context, md Metadata) context.Context {
function FromClientContext (line 99) | func FromClientContext(ctx context.Context) (Metadata, bool) {
function AppendToClientContext (line 106) | func AppendToClientContext(ctx context.Context, kv ...string) context.Co...
function MergeToClientContext (line 119) | func MergeToClientContext(ctx context.Context, cmd Metadata) context.Con...
FILE: metadata/metadata_test.go
function TestNew (line 9) | func TestNew(t *testing.T) {
function TestMetadata_Get (line 38) | func TestMetadata_Get(t *testing.T) {
function TestMetadata_Values (line 70) | func TestMetadata_Values(t *testing.T) {
function TestMetadata_Set (line 102) | func TestMetadata_Set(t *testing.T) {
function TestMetadata_Add (line 142) | func TestMetadata_Add(t *testing.T) {
function TestClientContext (line 182) | func TestClientContext(t *testing.T) {
function TestServerContext (line 215) | func TestServerContext(t *testing.T) {
function TestAppendToClientContext (line 248) | func TestAppendToClientContext(t *testing.T) {
function TestAppendToClientContextThatPanics (line 285) | func TestAppendToClientContextThatPanics(t *testing.T) {
function TestMergeToClientContext (line 303) | func TestMergeToClientContext(t *testing.T) {
function TestMetadata_Range (line 339) | func TestMetadata_Range(t *testing.T) {
function TestMetadata_Clone (line 360) | func TestMetadata_Clone(t *testing.T) {
function TestMetadata_CloneDeepCopy (line 398) | func TestMetadata_CloneDeepCopy(t *testing.T) {
FILE: middleware/auth/jwt/jwt.go
type authKey (line 15) | type authKey struct
constant bearerWord (line 20) | bearerWord string = "Bearer"
constant bearerFormat (line 23) | bearerFormat string = "Bearer %s"
constant authorizationKey (line 26) | authorizationKey string = "Authorization"
constant reason (line 29) | reason string = "UNAUTHORIZED"
type Option (line 46) | type Option
type options (line 49) | type options struct
function WithSigningMethod (line 57) | func WithSigningMethod(method jwt.SigningMethod) Option {
function WithClaims (line 66) | func WithClaims(f func() jwt.Claims) Option {
function WithTokenHeader (line 73) | func WithTokenHeader(header map[string]any) Option {
function WithParserOptions (line 82) | func WithParserOptions(opts ...jwt.ParserOption) Option {
function Server (line 89) | func Server(keyFunc jwt.Keyfunc, opts ...Option) middleware.Middleware {
function Client (line 141) | func Client(keyProvider jwt.Keyfunc, opts ...Option) middleware.Middlewa...
function NewContext (line 179) | func NewContext(ctx context.Context, info jwt.Claims) context.Context {
function FromContext (line 184) | func FromContext(ctx context.Context) (token jwt.Claims, ok bool) {
FILE: middleware/auth/jwt/jwt_test.go
type headerCarrier (line 21) | type headerCarrier
method Get (line 23) | func (hc headerCarrier) Get(key string) string { return http.Header(hc...
method Set (line 25) | func (hc headerCarrier) Set(key string, value string) { http.Header(hc...
method Add (line 27) | func (hc headerCarrier) Add(key string, value string) { http.Header(hc...
method Keys (line 30) | func (hc headerCarrier) Keys() []string {
method Values (line 39) | func (hc headerCarrier) Values(key string) []string {
function newTokenHeader (line 43) | func newTokenHeader(headerKey string, token string) *headerCarrier {
type Transport (line 49) | type Transport struct
method Kind (line 56) | func (tr *Transport) Kind() transport.Kind {
method Endpoint (line 60) | func (tr *Transport) Endpoint() string {
method Operation (line 64) | func (tr *Transport) Operation() string {
method RequestHeader (line 68) | func (tr *Transport) RequestHeader() transport.Header {
method ReplyHeader (line 72) | func (tr *Transport) ReplyHeader() transport.Header {
type CustomerClaims (line 76) | type CustomerClaims struct
function TestJWTServerParse (line 81) | func TestJWTServerParse(t *testing.T) {
function TestServer (line 177) | func TestServer(t *testing.T) {
function TestClient (line 275) | func TestClient(t *testing.T) {
function TestTokenExpire (line 322) | func TestTokenExpire(t *testing.T) {
function TestMissingKeyFunc (line 347) | func TestMissingKeyFunc(t *testing.T) {
function TestClientWithClaims (line 389) | func TestClientWithClaims(t *testing.T) {
function TestClientWithHeader (line 430) | func TestClientWithHeader(t *testing.T) {
function TestClientMissKey (line 463) | func TestClientMissKey(t *testing.T) {
function TestNewContextAndFromContext (line 504) | func TestNewContextAndFromContext(t *testing.T) {
function TestWithParserOptions (line 527) | func TestWithParserOptions(t *testing.T) {
function TestWithParserOptionsConcurrent (line 685) | func TestWithParserOptionsConcurrent(t *testing.T) {
function TestWithParserOptionsEmpty (line 731) | func TestWithParserOptionsEmpty(t *testing.T) {
FILE: middleware/circuitbreaker/circuitbreaker.go
type Option (line 19) | type Option
function WithGroup (line 23) | func WithGroup(g *group.Group[circuitbreaker.CircuitBreaker]) Option {
function WithCircuitBreaker (line 30) | func WithCircuitBreaker(genBreakerFunc func() circuitbreaker.CircuitBrea...
type options (line 38) | type options struct
function Client (line 44) | func Client(opts ...Option) middleware.Middleware {
FILE: middleware/circuitbreaker/circuitbreaker_test.go
type transportMock (line 14) | type transportMock struct
method Kind (line 24) | func (tr *transportMock) Kind() transport.Kind {
method Endpoint (line 28) | func (tr *transportMock) Endpoint() string {
method Operation (line 32) | func (tr *transportMock) Operation() string {
method RequestHeader (line 36) | func (tr *transportMock) RequestHeader() transport.Header {
method ReplyHeader (line 40) | func (tr *transportMock) ReplyHeader() transport.Header {
type circuitBreakerMock (line 20) | type circuitBreakerMock struct
method Allow (line 44) | func (c *circuitBreakerMock) Allow() error { return c.err }
method MarkSuccess (line 45) | func (c *circuitBreakerMock) MarkSuccess() {}
method MarkFailed (line 46) | func (c *circuitBreakerMock) MarkFailed() {}
function Test_WithGroup (line 48) | func Test_WithGroup(t *testing.T) {
function TestServer (line 61) | func TestServer(_ *testing.T) {
FILE: middleware/logging/logging.go
type Redacter (line 18) | type Redacter interface
function Server (line 23) | func Server(logger log.Logger) middleware.Middleware {
function Client (line 63) | func Client(logger log.Logger) middleware.Middleware {
function extractArgs (line 103) | func extractArgs(req any) string {
function extractError (line 114) | func extractError(err error) (log.Level, string) {
FILE: middleware/logging/logging_test.go
type Transport (line 16) | type Transport struct
method Kind (line 22) | func (tr *Transport) Kind() transport.Kind {
method Endpoint (line 26) | func (tr *Transport) Endpoint() string {
method Operation (line 30) | func (tr *Transport) Operation() string {
method RequestHeader (line 34) | func (tr *Transport) RequestHeader() transport.Header {
method ReplyHeader (line 38) | func (tr *Transport) ReplyHeader() transport.Header {
function TestHTTP (line 42) | func TestHTTP(t *testing.T) {
type dummy (line 102) | type dummy struct
type dummyStringer (line 105) | type dummyStringer struct
method String (line 113) | func (d *dummyStringer) String() string {
type dummyStringerRedacter (line 108) | type dummyStringerRedacter struct
method String (line 117) | func (d *dummyStringerRedacter) String() string {
method Redact (line 121) | func (d *dummyStringerRedacter) Redact() string {
function TestExtractArgs (line 125) | func TestExtractArgs(t *testing.T) {
function TestExtractError (line 154) | func TestExtractError(t *testing.T) {
type extractKeyValues (line 181) | type extractKeyValues
method Log (line 183) | func (l *extractKeyValues) Log(_ log.Level, kv ...any) error { *l = ap...
function TestServer_CallerPath (line 185) | func TestServer_CallerPath(t *testing.T) {
function TestClient_CallerPath (line 211) | func TestClient_CallerPath(t *testing.T) {
FILE: middleware/metadata/metadata.go
type Option (line 13) | type Option
type options (line 15) | type options struct
method hasPrefix (line 20) | func (o *options) hasPrefix(key string) bool {
function WithConstants (line 31) | func WithConstants(md metadata.Metadata) Option {
function WithPropagatedPrefix (line 38) | func WithPropagatedPrefix(prefix ...string) Option {
function Server (line 45) | func Server(opts ...Option) middleware.Middleware {
function Client (line 75) | func Client(opts ...Option) middleware.Middleware {
FILE: middleware/metadata/metadata_test.go
type headerCarrier (line 14) | type headerCarrier
method Get (line 16) | func (hc headerCarrier) Get(key string) string { return http.Header(hc...
method Set (line 18) | func (hc headerCarrier) Set(key string, value string) { http.Header(hc...
method Add (line 20) | func (hc headerCarrier) Add(key string, value string) { http.Header(hc...
method Keys (line 23) | func (hc headerCarrier) Keys() []string {
method Values (line 32) | func (hc headerCarrier) Values(key string) []string {
type testTransport (line 36) | type testTransport struct
method Kind (line 38) | func (tr *testTransport) Kind() transport.Kind { return tra...
method Endpoint (line 39) | func (tr *testTransport) Endpoint() string { return "" }
method Operation (line 40) | func (tr *testTransport) Operation() string { return "" }
method RequestHeader (line 41) | func (tr *testTransport) RequestHeader() transport.Header { return tr....
method ReplyHeader (line 42) | func (tr *testTransport) ReplyHeader() transport.Header { return tr....
function TestSever (line 55) | func TestSever(t *testing.T) {
function TestClient (line 88) | func TestClient(t *testing.T) {
function TestWithConstants (line 131) | func TestWithConstants(t *testing.T) {
function TestOptions_WithPropagatedPrefix (line 147) | func TestOptions_WithPropagatedPrefix(t *testing.T) {
function TestOptions_hasPrefix (line 159) | func TestOptions_hasPrefix(t *testing.T) {
FILE: middleware/metrics/metrics.go
constant metricLabelKind (line 19) | metricLabelKind = "kind"
constant metricLabelOperation (line 20) | metricLabelOperation = "operation"
constant metricLabelCode (line 21) | metricLabelCode = "code"
constant metricLabelReason (line 22) | metricLabelReason = "reason"
constant DefaultServerSecondsHistogramName (line 26) | DefaultServerSecondsHistogramName = "server_requests_seconds"
constant DefaultServerRequestsCounterName (line 27) | DefaultServerRequestsCounterName = "server_requests_code_total"
constant DefaultClientSecondsHistogramName (line 28) | DefaultClientSecondsHistogramName = "client_requests_seconds"
constant DefaultClientRequestsCounterName (line 29) | DefaultClientRequestsCounterName = "client_requests_code_total"
type Option (line 33) | type Option
function WithRequests (line 36) | func WithRequests(c metric.Int64Counter) Option {
function WithSeconds (line 44) | func WithSeconds(histogram metric.Float64Histogram) Option {
function DefaultRequestsCounter (line 53) | func DefaultRequestsCounter(meter metric.Meter, histogramName string) (m...
function DefaultSecondsHistogram (line 60) | func DefaultSecondsHistogram(meter metric.Meter, histogramName string) (...
function DefaultSecondsHistogramView (line 74) | func DefaultSecondsHistogramView(histogramName string) metricsdk.View {
type options (line 94) | type options struct
function Server (line 102) | func Server(opts ...Option) middleware.Middleware {
function Client (line 160) | func Client(opts ...Option) middleware.Middleware {
FILE: middleware/metrics/metrics_test.go
type dummyExporter (line 25) | type dummyExporter struct
method Temporality (line 30) | func (x *dummyExporter) Temporality(kind sdkmetric.InstrumentKind) met...
method Aggregation (line 34) | func (x *dummyExporter) Aggregation(kind sdkmetric.InstrumentKind) sdk...
method Export (line 38) | func (x *dummyExporter) Export(ctx context.Context, resourceMetrics *m...
method ForceFlush (line 51) | func (x *dummyExporter) ForceFlush(ctx context.Context) error {
method Shutdown (line 55) | func (x *dummyExporter) Shutdown(ctx context.Context) error {
method String (line 59) | func (x *dummyExporter) String() string {
function init (line 67) | func init() {
function TestWithRequests (line 92) | func TestWithRequests(t *testing.T) {
function TestWithSeconds (line 114) | func TestWithSeconds(t *testing.T) {
function TestServer (line 136) | func TestServer(t *testing.T) {
function TestClient (line 198) | func TestClient(t *testing.T) {
FILE: middleware/metrics/otel.go
function EnableOTELExemplar (line 5) | func EnableOTELExemplar() error {
FILE: middleware/middleware.go
type Handler (line 8) | type Handler
type Middleware (line 11) | type Middleware
function Chain (line 14) | func Chain(m ...Middleware) Middleware {
FILE: middleware/middleware_test.go
function TestChain (line 12) | func TestChain(t *testing.T) {
function test1Middleware (line 33) | func test1Middleware(handler Handler) Handler {
function test2Middleware (line 43) | func test2Middleware(handler Handler) Handler {
function test3Middleware (line 53) | func test3Middleware(handler Handler) Handler {
FILE: middleware/ratelimit/ratelimit.go
type Option (line 17) | type Option
function WithLimiter (line 21) | func WithLimiter(limiter ratelimit.Limiter) Option {
type options (line 27) | type options struct
function Server (line 32) | func Server(opts ...Option) middleware.Middleware {
FILE: middleware/ratelimit/ratelimit_test.go
type ratelimitMock (line 12) | type ratelimitMock struct
method Allow (line 20) | func (r *ratelimitMock) Allow() (ratelimit.DoneFunc, error) {
type ratelimitReachedMock (line 15) | type ratelimitReachedMock struct
method Allow (line 26) | func (r *ratelimitReachedMock) Allow() (ratelimit.DoneFunc, error) {
function Test_WithLimiter (line 32) | func Test_WithLimiter(t *testing.T) {
function TestServer (line 43) | func TestServer(t *testing.T) {
FILE: middleware/recovery/recovery.go
type Latency (line 14) | type Latency struct
type HandlerFunc (line 20) | type HandlerFunc
type Option (line 23) | type Option
type options (line 25) | type options struct
function WithHandler (line 30) | func WithHandler(h HandlerFunc) Option {
function Recovery (line 37) | func Recovery(opts ...Option) middleware.Middleware {
FILE: middleware/recovery/recovery_test.go
function TestOnce (line 11) | func TestOnce(t *testing.T) {
function TestNotPanic (line 31) | func TestNotPanic(t *testing.T) {
FILE: middleware/selector/selector.go
type transporter (line 13) | type transporter
type MatchFunc (line 14) | type MatchFunc
type Builder (line 29) | type Builder struct
method Prefix (line 52) | func (b *Builder) Prefix(prefix ...string) *Builder {
method Regex (line 58) | func (b *Builder) Regex(regex ...string) *Builder {
method Path (line 64) | func (b *Builder) Path(path ...string) *Builder {
method Match (line 70) | func (b *Builder) Match(fn MatchFunc) *Builder {
method Build (line 76) | func (b *Builder) Build() middleware.Middleware {
method matches (line 93) | func (b *Builder) matches(ctx context.Context, transporter transporter...
function Server (line 42) | func Server(ms ...middleware.Middleware) *Builder {
function Client (line 47) | func Client(ms ...middleware.Middleware) *Builder {
function selector (line 126) | func selector(transporter transporter, match func(context.Context, trans...
function pathMatch (line 137) | func pathMatch(path string, operation string) bool {
function prefixMatch (line 141) | func prefixMatch(prefix string, operation string) bool {
FILE: middleware/selector/selector_test.go
type Transport (line 15) | type Transport struct
method Kind (line 22) | func (tr *Transport) Kind() transport.Kind {
method Endpoint (line 26) | func (tr *Transport) Endpoint() string {
method Operation (line 30) | func (tr *Transport) Operation() string {
method RequestHeader (line 34) | func (tr *Transport) RequestHeader() transport.Header {
method ReplyHeader (line 38) | func (tr *Transport) ReplyHeader() transport.Header {
type mockHeader (line 42) | type mockHeader struct
method Get (line 46) | func (m *mockHeader) Get(key string) string {
method Set (line 54) | func (m *mockHeader) Set(key, value string) {
method Add (line 58) | func (m *mockHeader) Add(key, value string) {
method Keys (line 62) | func (m *mockHeader) Keys() []string {
method Values (line 70) | func (m *mockHeader) Values(key string) []string {
function TestMatch (line 74) | func TestMatch(t *testing.T) {
function TestMatchClient (line 110) | func TestMatchClient(t *testing.T) {
function TestFunc (line 146) | func TestFunc(t *testing.T) {
function TestHeaderFunc (line 191) | func TestHeaderFunc(t *testing.T) {
function testMiddleware (line 255) | func testMiddleware(handler middleware.Handler) middleware.Handler {
function Test_RegexMatch (line 262) | func Test_RegexMatch(t *testing.T) {
function Test_InvalidRegexSkipped (line 340) | func Test_InvalidRegexSkipped(t *testing.T) {
function Test_matches (line 351) | func Test_matches(t *testing.T) {
FILE: middleware/tracing/metadata.go
constant serviceHeader (line 12) | serviceHeader = "x-md-service-name"
type Metadata (line 15) | type Metadata struct
method Inject (line 20) | func (b Metadata) Inject(ctx context.Context, carrier propagation.Text...
method Extract (line 28) | func (b Metadata) Extract(parent context.Context, carrier propagation....
method Fields (line 44) | func (b Metadata) Fields() []string {
FILE: middleware/tracing/metadata_test.go
function TestMetadata_Inject (line 14) | func TestMetadata_Inject(t *testing.T) {
function TestMetadata_Extract (line 48) | func TestMetadata_Extract(t *testing.T) {
function TestFields (line 102) | func TestFields(t *testing.T) {
FILE: middleware/tracing/span.go
function setClientSpan (line 20) | func setClientSpan(ctx context.Context, span trace.Span, m any) {
function setServerSpan (line 59) | func setServerSpan(ctx context.Context, span trace.Span, m any) {
function parseFullMethod (line 104) | func parseFullMethod(fullMethod string) (string, []attribute.KeyValue) {
function peerAttr (line 123) | func peerAttr(addr string) []attribute.KeyValue {
function parseTarget (line 139) | func parseTarget(endpoint string) (address string, err error) {
FILE: middleware/tracing/span_test.go
function Test_parseFullMethod (line 21) | func Test_parseFullMethod(t *testing.T) {
function Test_peerAttr (line 67) | func Test_peerAttr(t *testing.T) {
function Test_parseTarget (line 112) | func Test_parseTarget(t *testing.T) {
function TestSetServerSpan (line 182) | func TestSetServerSpan(_ *testing.T) {
function TestSetClientSpan (line 215) | func TestSetClientSpan(_ *testing.T) {
FILE: middleware/tracing/statshandler.go
type ClientHandler (line 13) | type ClientHandler struct
method HandleConn (line 16) | func (c *ClientHandler) HandleConn(_ context.Context, _ stats.ConnStat...
method TagConn (line 21) | func (c *ClientHandler) TagConn(ctx context.Context, _ *stats.ConnTagI...
method HandleRPC (line 26) | func (c *ClientHandler) HandleRPC(ctx context.Context, rs stats.RPCSta...
method TagRPC (line 41) | func (c *ClientHandler) TagRPC(ctx context.Context, _ *stats.RPCTagInf...
FILE: middleware/tracing/statshandler_test.go
type ctxKey (line 14) | type ctxKey
constant testKey (line 16) | testKey ctxKey = "MY_TEST_KEY"
function TestClient_HandleConn (line 18) | func TestClient_HandleConn(_ *testing.T) {
function TestClient_TagConn (line 22) | func TestClient_TagConn(t *testing.T) {
function TestClient_TagRPC (line 31) | func TestClient_TagRPC(t *testing.T) {
type mockSpan (line 40) | type mockSpan struct
method SpanContext (line 45) | func (m *mockSpan) SpanContext() trace.SpanContext {
function TestClient_HandleRPC (line 49) | func TestClient_HandleRPC(_ *testing.T) {
FILE: middleware/tracing/tracer.go
type Tracer (line 18) | type Tracer struct
method Start (line 48) | func (t *Tracer) Start(ctx context.Context, operation string, carrier ...
method End (line 63) | func (t *Tracer) End(_ context.Context, span trace.Span, m any, err er...
function NewTracer (line 25) | func NewTracer(kind trace.SpanKind, opts ...Option) *Tracer {
FILE: middleware/tracing/tracer_test.go
function TestNewTracer (line 14) | func TestNewTracer(t *testing.T) {
function TestTracer_End (line 33) | func TestTracer_End(_ *testing.T) {
FILE: middleware/tracing/tracing.go
type Option (line 16) | type Option
type options (line 18) | type options struct
function WithPropagator (line 25) | func WithPropagator(propagator propagation.TextMapPropagator) Option {
function WithTracerProvider (line 33) | func WithTracerProvider(provider trace.TracerProvider) Option {
function WithTracerName (line 40) | func WithTracerName(tracerName string) Option {
function Server (line 47) | func Server(opts ...Option) middleware.Middleware {
function Client (line 63) | func Client(opts ...Option) middleware.Middleware {
function TraceID (line 79) | func TraceID() log.Valuer {
function SpanID (line 89) | func SpanID() log.Valuer {
FILE: middleware/tracing/tracing_test.go
type headerCarrier (line 21) | type headerCarrier
method Get (line 24) | func (hc headerCarrier) Get(key string) string {
method Set (line 29) | func (hc headerCarrier) Set(key string, value string) {
method Add (line 34) | func (hc headerCarrier) Add(key string, value string) {
method Keys (line 39) | func (hc headerCarrier) Keys() []string {
method Values (line 48) | func (hc headerCarrier) Values(key string) []string {
type mockTransport (line 52) | type mockTransport struct
method Kind (line 60) | func (tr *mockTransport) Kind() transport.Kind { return tr....
method Endpoint (line 61) | func (tr *mockTransport) Endpoint() string { return tr....
method Operation (line 62) | func (tr *mockTransport) Operation() string { return tr....
method RequestHeader (line 63) | func (tr *mockTransport) RequestHeader() transport.Header { return tr....
method ReplyHeader (line 64) | func (tr *mockTransport) ReplyHeader() transport.Header { return tr....
method Request (line 65) | func (tr *mockTransport) Request() *http.Request {
method PathTemplate (line 74) | func (tr *mockTransport) PathTemplate() string { return "" }
method Response (line 75) | func (tr *mockTransport) Response() http.ResponseWriter {
function TestTracer (line 79) | func TestTracer(t *testing.T) {
function TestServer (line 113) | func TestServer(t *testing.T) {
function TestClient (line 184) | func TestClient(t *testing.T) {
FILE: middleware/validate/validate.go
type ValidatorFunc (line 11) | type ValidatorFunc
type validator (line 14) | type validator interface
function Validator (line 44) | func Validator(validators ...ValidatorFunc) middleware.Middleware {
FILE: middleware/validate/validate_test.go
type protoVali (line 13) | type protoVali struct
method Validate (line 19) | func (v protoVali) Validate() error {
function TestTable (line 26) | func TestTable(t *testing.T) {
FILE: options.go
type Option (line 15) | type Option
type options (line 18) | type options struct
function ID (line 42) | func ID(id string) Option {
function Name (line 47) | func Name(name string) Option {
function Version (line 52) | func Version(version string) Option {
function Metadata (line 57) | func Metadata(md map[string]string) Option {
function Endpoint (line 62) | func Endpoint(endpoints ...*url.URL) Option {
function Context (line 67) | func Context(ctx context.Context) Option {
function Logger (line 72) | func Logger(logger log.Logger) Option {
function Server (line 77) | func Server(srv ...transport.Server) Option {
function Signal (line 82) | func Signal(sigs ...os.Signal) Option {
function Registrar (line 87) | func Registrar(r registry.Registrar) Option {
function RegistrarTimeout (line 92) | func RegistrarTimeout(t time.Duration) Option {
function StopTimeout (line 97) | func StopTimeout(t time.Duration) Option {
function BeforeStart (line 104) | func BeforeStart(fn func(context.Context) error) Option {
function BeforeStop (line 111) | func BeforeStop(fn func(context.Context) error) Option {
function AfterStart (line 118) | func AfterStart(fn func(context.Context) error) Option {
function AfterStop (line 125) | func AfterStop(fn func(context.Context) error) Option {
FILE: options_test.go
function TestID (line 17) | func TestID(t *testing.T) {
function TestName (line 26) | func TestName(t *testing.T) {
function TestVersion (line 35) | func TestVersion(t *testing.T) {
function TestMetadata (line 44) | func TestMetadata(t *testing.T) {
function TestEndpoint (line 56) | func TestEndpoint(t *testing.T) {
function TestContext (line 68) | func TestContext(t *testing.T) {
function TestLogger (line 80) | func TestLogger(t *testing.T) {
type mockServer (line 89) | type mockServer struct
method Start (line 93) | func (m *mockServer) Start(_ context.Context) error { return nil }
method Stop (line 94) | func (m *mockServer) Stop(ctx context.Context) error {
function TestServer (line 101) | func TestServer(t *testing.T) {
type mockSignal (line 112) | type mockSignal struct
method String (line 114) | func (m *mockSignal) String() string { return "sig" }
method Signal (line 115) | func (m *mockSignal) Signal() {}
function TestSignal (line 117) | func TestSignal(t *testing.T) {
type mockRegistrar (line 128) | type mockRegistrar struct
method Register (line 130) | func (m *mockRegistrar) Register(_ context.Context, _ *registry.Servic...
method Deregister (line 134) | func (m *mockRegistrar) Deregister(_ context.Context, _ *registry.Serv...
function TestRegistrar (line 138) | func TestRegistrar(t *testing.T) {
function TestRegistrarTimeout (line 147) | func TestRegistrarTimeout(t *testing.T) {
function TestStopTimeout (line 156) | func TestStopTimeout(t *testing.T) {
function TestBeforeStart (line 165) | func TestBeforeStart(t *testing.T) {
function TestBeforeStop (line 174) | func TestBeforeStop(t *testing.T) {
function TestAfterStart (line 183) | func TestAfterStart(t *testing.T) {
function TestAfterStop (line 192) | func TestAfterStop(t *testing.T) {
FILE: registry/registry.go
type Registrar (line 10) | type Registrar interface
type Discovery (line 18) | type Discovery interface
type Watcher (line 26) | type Watcher interface
type ServiceInstance (line 37) | type ServiceInstance struct
method String (line 53) | func (i *ServiceInstance) String() string {
method Equal (line 58) | func (i *ServiceInstance) Equal(o any) bool {
FILE: selector/balancer.go
type Balancer (line 9) | type Balancer interface
type BalancerBuilder (line 14) | type BalancerBuilder interface
type WeightedNode (line 19) | type WeightedNode interface
type WeightedNodeBuilder (line 36) | type WeightedNodeBuilder interface
FILE: selector/default_node.go
type DefaultNode (line 12) | type DefaultNode struct
method Scheme (line 22) | func (n *DefaultNode) Scheme() string {
method Address (line 27) | func (n *DefaultNode) Address() string {
method ServiceName (line 32) | func (n *DefaultNode) ServiceName() string {
method InitialWeight (line 37) | func (n *DefaultNode) InitialWeight() *int64 {
method Version (line 42) | func (n *DefaultNode) Version() string {
method Metadata (line 47) | func (n *DefaultNode) Metadata() map[string]string {
function NewNode (line 52) | func NewNode(scheme, addr string, ins *registry.ServiceInstance) Node {
FILE: selector/default_selector.go
type Default (line 14) | type Default struct
method Select (line 22) | func (d *Default) Select(ctx context.Context, opts ...SelectOption) (s...
method Apply (line 65) | func (d *Default) Apply(nodes []Node) {
type DefaultBuilder (line 75) | type DefaultBuilder struct
method Build (line 81) | func (db *DefaultBuilder) Build() Selector {
FILE: selector/filter.go
type NodeFilter (line 6) | type NodeFilter
FILE: selector/filter/version.go
function Version (line 10) | func Version(version string) selector.NodeFilter {
FILE: selector/filter/version_test.go
function TestVersion (line 12) | func TestVersion(t *testing.T) {
FILE: selector/global.go
type wrapSelector (line 8) | type wrapSelector struct
function GlobalSelector (line 11) | func GlobalSelector() Builder {
function SetGlobalSelector (line 19) | func SetGlobalSelector(builder Builder) {
FILE: selector/node/direct/direct.go
constant defaultWeight (line 12) | defaultWeight = 100
type Node (line 21) | type Node struct
method Pick (line 36) | func (n *Node) Pick() selector.DoneFunc {
method Weight (line 43) | func (n *Node) Weight() float64 {
method PickElapsed (line 50) | func (n *Node) PickElapsed() time.Duration {
method Raw (line 54) | func (n *Node) Raw() selector.Node {
type Builder (line 29) | type Builder struct
method Build (line 32) | func (*Builder) Build(n selector.Node) selector.WeightedNode {
FILE: selector/node/direct/direct_test.go
function TestDirect (line 13) | func TestDirect(t *testing.T) {
function TestDirectDefaultWeight (line 43) | func TestDirectDefaultWeight(t *testing.T) {
FILE: selector/node/ewma/node.go
constant tau (line 16) | tau = int64(time.Millisecond * 600)
constant penalty (line 18) | penalty = uint64(time.Microsecond * 100)
type Node (line 27) | type Node struct
method health (line 69) | func (n *Node) health() uint64 {
method load (line 73) | func (n *Node) load() (load uint64) {
method predict (line 93) | func (n *Node) predict(avgLag int64, now int64) (predict int64) {
method Pick (line 117) | func (n *Node) Pick() selector.DoneFunc {
method Weight (line 168) | func (n *Node) Weight() (weight float64) {
method PickElapsed (line 185) | func (n *Node) PickElapsed() time.Duration {
method Raw (line 189) | func (n *Node) Raw() selector.Node {
type nodeWeight (line 46) | type nodeWeight struct
type Builder (line 52) | type Builder struct
method Build (line 57) | func (b *Builder) Build(n selector.Node) selector.WeightedNode {
FILE: selector/node/ewma/node_test.go
function TestDirect (line 14) | func TestDirect(t *testing.T) {
function TestDirectError (line 55) | func TestDirectError(t *testing.T) {
function TestDirectErrorHandler (line 88) | func TestDirectErrorHandler(t *testing.T) {
function BenchmarkPickAndWeight (line 129) | func BenchmarkPickAndWeight(b *testing.B) {
FILE: selector/options.go
type SelectOptions (line 4) | type SelectOptions struct
type SelectOption (line 9) | type SelectOption
function WithNodeFilter (line 12) | func WithNodeFilter(fn ...NodeFilter) SelectOption {
FILE: selector/p2c/p2c.go
constant forcePick (line 15) | forcePick = time.Second * 3
constant Name (line 17) | Name = "p2c"
type Option (line 23) | type Option
type options (line 26) | type options struct
function New (line 29) | func New(opts ...Option) selector.Selector {
type Balancer (line 34) | type Balancer struct
method prePick (line 41) | func (s *Balancer) prePick(nodes []selector.WeightedNode) (nodeA selec...
method Pick (line 54) | func (s *Balancer) Pick(_ context.Context, nodes []selector.WeightedNo...
function NewBuilder (line 83) | func NewBuilder(opts ...Option) selector.Builder {
type Builder (line 95) | type Builder struct
method Build (line 98) | func (b *Builder) Build() selector.Balancer {
FILE: selector/p2c/p2c_test.go
function TestWrr3 (line 18) | func TestWrr3(t *testing.T) {
function TestEmpty (line 86) | func TestEmpty(t *testing.T) {
function TestOne (line 94) | func TestOne(t *testing.T) {
FILE: selector/peer.go
type peerKey (line 7) | type peerKey struct
type Peer (line 11) | type Peer struct
function NewPeerContext (line 17) | func NewPeerContext(ctx context.Context, p *Peer) context.Context {
function FromPeerContext (line 22) | func FromPeerContext(ctx context.Context) (p *Peer, ok bool) {
FILE: selector/peer_test.go
function TestPeer (line 8) | func TestPeer(t *testing.T) {
function TestNotPeer (line 19) | func TestNotPeer(t *testing.T) {
FILE: selector/random/random.go
constant Name (line 13) | Name = "random"
type Option (line 19) | type Option
type options (line 22) | type options struct
type Balancer (line 25) | type Balancer struct
method Pick (line 33) | func (p *Balancer) Pick(_ context.Context, nodes []selector.WeightedNo...
function New (line 28) | func New(opts ...Option) selector.Selector {
function NewBuilder (line 44) | func NewBuilder(opts ...Option) selector.Builder {
type Builder (line 56) | type Builder struct
method Build (line 59) | func (b *Builder) Build() selector.Balancer {
FILE: selector/random/random_test.go
function TestWrr (line 12) | func TestWrr(t *testing.T) {
function TestEmpty (line 65) | func TestEmpty(t *testing.T) {
FILE: selector/selector.go
type Selector (line 13) | type Selector interface
type Rebalancer (line 22) | type Rebalancer interface
type Builder (line 28) | type Builder interface
type Node (line 33) | type Node interface
type DoneInfo (line 56) | type DoneInfo struct
type ReplyMD (line 69) | type ReplyMD interface
type DoneFunc (line 74) | type DoneFunc
FILE: selector/selector_test.go
type mockWeightedNode (line 17) | type mockWeightedNode struct
method Raw (line 24) | func (n *mockWeightedNode) Raw() Node {
method Weight (line 29) | func (n *mockWeightedNode) Weight() float64 {
method Pick (line 37) | func (n *mockWeightedNode) Pick() DoneFunc {
method PickElapsed (line 44) | func (n *mockWeightedNode) PickElapsed() time.Duration {
type mockWeightedNodeBuilder (line 48) | type mockWeightedNodeBuilder struct
method Build (line 50) | func (b *mockWeightedNodeBuilder) Build(n Node) WeightedNode {
function mockFilter (line 54) | func mockFilter(version string) NodeFilter {
type mockBalancerBuilder (line 66) | type mockBalancerBuilder struct
method Build (line 68) | func (b *mockBalancerBuilder) Build() Balancer {
type mockBalancer (line 72) | type mockBalancer struct
method Pick (line 74) | func (b *mockBalancer) Pick(_ context.Context, nodes []WeightedNode) (...
type mockMustErrorBalancerBuilder (line 85) | type mockMustErrorBalancerBuilder struct
method Build (line 87) | func (b *mockMustErrorBalancerBuilder) Build() Balancer {
type mockMustErrorBalancer (line 91) | type mockMustErrorBalancer struct
method Pick (line 93) | func (b *mockMustErrorBalancer) Pick(_ context.Context, _ []WeightedNo...
function TestDefault (line 97) | func TestDefault(t *testing.T) {
function TestWithoutApply (line 222) | func TestWithoutApply(t *testing.T) {
function TestNoPick (line 240) | func TestNoPick(t *testing.T) {
function TestGlobalSelector (line 280) | func TestGlobalSelector(t *testing.T) {
FILE: selector/wrr/wrr.go
constant Name (line 13) | Name = "wrr"
type Option (line 19) | type Option
type options (line 22) | type options struct
type Balancer (line 25) | type Balancer struct
method Pick (line 59) | func (p *Balancer) Pick(_ context.Context, nodes []selector.WeightedNo...
function equalNodes (line 32) | func equalNodes(a, b []selector.WeightedNode) bool {
function New (line 54) | func New(opts ...Option) selector.Selector {
function NewBuilder (line 110) | func NewBuilder(opts ...Option) selector.Builder {
type Builder (line 122) | type Builder struct
method Build (line 125) | func (b *Builder) Build() selector.Balancer {
FILE: selector/wrr/wrr_test.go
function TestWrr (line 14) | func TestWrr(t *testing.T) {
function TestCurrentWeightCleanup (line 62) | func TestCurrentWeightCleanup(t *testing.T) {
function TestCleanupOnlyWhenNodesChange (line 118) | func TestCleanupOnlyWhenNodesChange(t *testing.T) {
type mockWeightedNode (line 240) | type mockWeightedNode struct
method Raw (line 245) | func (m *mockWeightedNode) Raw() selector.Node { return nil }
method Weight (line 246) | func (m *mockWeightedNode) Weight() float64 { return m.weight }
method Address (line 247) | func (m *mockWeightedNode) Address() string { return m.address }
method Pick (line 248) | func (m *mockWeightedNode) Pick() selector.DoneFunc {
method PickElapsed (line 251) | func (m *mockWeightedNode) PickElapsed() time.Duration { return 0 }
method Scheme (line 252) | func (m *mockWeightedNode) Scheme() string { return "http" }
method ServiceName (line 253) | func (m *mockWeightedNode) ServiceName() string { return "test" }
method InitialWeight (line 254) | func (m *mockWeightedNode) InitialWeight() *int64 { return nil }
method Version (line 255) | func (m *mockWeightedNode) Version() string { return "v1.0...
method Metadata (line 256) | func (m *mockWeightedNode) Metadata() map[string]string { return nil }
function TestEmpty (line 258) | func TestEmpty(t *testing.T) {
function BenchmarkPickWithSameNodes (line 268) | func BenchmarkPickWithSameNodes(b *testing.B) {
function BenchmarkPickWithChangingNodes (line 297) | func BenchmarkPickWithChangingNodes(b *testing.B) {
FILE: transport/grpc/balancer.go
constant balancerName (line 14) | balancerName = "selector"
function init (line 22) | func init() {
type balancerBuilder (line 33) | type balancerBuilder struct
method Build (line 38) | func (b *balancerBuilder) Build(info base.PickerBuildInfo) balancer.Pi...
type balancerPicker (line 59) | type balancerPicker struct
method Pick (line 64) | func (p *balancerPicker) Pick(info balancer.PickInfo) (balancer.PickRe...
type Trailer (line 91) | type Trailer
method Get (line 94) | func (t Trailer) Get(k string) string {
type grpcNode (line 102) | type grpcNode struct
FILE: transport/grpc/balancer_test.go
function TestTrailer (line 13) | func TestTrailer(t *testing.T) {
function TestFilters (line 23) | func TestFilters(t *testing.T) {
FILE: transport/grpc/client.go
function init (line 27) | func init() {
type ClientOption (line 34) | type ClientOption
function WithEndpoint (line 37) | func WithEndpoint(endpoint string) ClientOption {
function WithSubset (line 45) | func WithSubset(size int) ClientOption {
function WithTimeout (line 52) | func WithTimeout(timeout time.Duration) ClientOption {
function WithMiddleware (line 59) | func WithMiddleware(m ...middleware.Middleware) ClientOption {
function WithStreamMiddleware (line 66) | func WithStreamMiddleware(m ...middleware.Middleware) ClientOption {
function WithDiscovery (line 73) | func WithDiscovery(d registry.Discovery) ClientOption {
function WithTLSConfig (line 80) | func WithTLSConfig(c *tls.Config) ClientOption {
function WithUnaryInterceptor (line 87) | func WithUnaryInterceptor(in ...grpc.UnaryClientInterceptor) ClientOption {
function WithStreamInterceptor (line 94) | func WithStreamInterceptor(in ...grpc.StreamClientInterceptor) ClientOpt...
function WithOptions (line 101) | func WithOptions(opts ...grpc.DialOption) ClientOption {
function WithNodeFilter (line 108) | func WithNodeFilter(filters ...selector.NodeFilter) ClientOption {
function WithHealthCheck (line 115) | func WithHealthCheck(healthCheck bool) ClientOption {
function WithLogger (line 125) | func WithLogger(log.Logger) ClientOption {
function WithPrintDiscoveryDebugLog (line 129) | func WithPrintDiscoveryDebugLog(p bool) ClientOption {
type clientOptions (line 136) | type clientOptions struct
function Dial (line 154) | func Dial(ctx context.Context, opts ...ClientOption) (*grpc.ClientConn, ...
function DialInsecure (line 159) | func DialInsecure(ctx context.Context, opts ...ClientOption) (*grpc.Clie...
function dial (line 163) | func dial(ctx context.Context, insecure bool, opts ...ClientOption) (*gr...
function unaryClientInterceptor (line 217) | func unaryClientInterceptor(ms []middleware.Middleware, timeout time.Dur...
type wrappedClientStream (line 253) | type wrappedClientStream struct
method Context (line 259) | func (w *wrappedClientStream) Context() context.Context {
method SendMsg (line 263) | func (w *wrappedClientStream) SendMsg(m any) error {
method RecvMsg (line 281) | func (w *wrappedClientStream) RecvMsg(m any) error {
function streamClientInterceptor (line 299) | func streamClientInterceptor(ms []middleware.Middleware, filters []selec...
FILE: transport/grpc/client_test.go
function TestWithEndpoint (line 16) | func TestWithEndpoint(t *testing.T) {
function TestWithTimeout (line 25) | func TestWithTimeout(t *testing.T) {
function TestWithMiddleware (line 34) | func TestWithMiddleware(t *testing.T) {
function TestWithStreamMiddleware (line 45) | func TestWithStreamMiddleware(t *testing.T) {
type mockRegistry (line 56) | type mockRegistry struct
method GetService (line 58) | func (m *mockRegistry) GetService(_ context.Context, _ string) ([]*reg...
method Watch (line 62) | func (m *mockRegistry) Watch(_ context.Context, _ string) (registry.Wa...
function TestWithDiscovery (line 66) | func TestWithDiscovery(t *testing.T) {
function TestWithTLSConfig (line 75) | func TestWithTLSConfig(t *testing.T) {
function EmptyMiddleware (line 84) | func EmptyMiddleware() middleware.Middleware {
function TestUnaryClientInterceptor (line 92) | func TestUnaryClientInterceptor(t *testing.T) {
function TestWithUnaryInterceptor (line 106) | func TestWithUnaryInterceptor(t *testing.T) {
function TestWithOptions (line 122) | func TestWithOptions(t *testing.T) {
function TestWithHealthCheck (line 133) | func TestWithHealthCheck(t *testing.T) {
function TestDial (line 143) | func TestDial(t *testing.T) {
function TestDialConn (line 154) | func TestDialConn(t *testing.T) {
FILE: transport/grpc/codec.go
function init (line 13) | func init() {
type codec (line 18) | type codec struct
method Marshal (line 20) | func (codec) Marshal(v any) ([]byte, error) {
method Unmarshal (line 28) | func (codec) Unmarshal(data []byte, v any) error {
method Name (line 36) | func (codec) Name() string {
FILE: transport/grpc/codec_test.go
function TestCodec (line 10) | func TestCodec(t *testing.T) {
FILE: transport/grpc/interceptor.go
method unaryServerInterceptor (line 17) | func (s *Server) unaryServerInterceptor() grpc.UnaryServerInterceptor {
type wrappedStream (line 51) | type wrappedStream struct
method Context (line 65) | func (w *wrappedStream) Context() context.Context {
method SendMsg (line 114) | func (w *wrappedStream) SendMsg(m any) error {
method RecvMsg (line 132) | func (w *wrappedStream) RecvMsg(m any) error {
function NewWrappedStream (line 57) | func NewWrappedStream(ctx context.Context, stream grpc.ServerStream, m m...
method streamServerInterceptor (line 70) | func (s *Server) streamServerInterceptor() grpc.StreamServerInterceptor {
type stream (line 105) | type stream struct
function GetStream (line 110) | func GetStream(ctx context.Context) grpc.ServerStream {
FILE: transport/grpc/resolver/direct/builder.go
constant name (line 9) | name = "direct"
function init (line 11) | func init() {
type directBuilder (line 15) | type directBuilder struct
method Build (line 25) | func (d *directBuilder) Build(target resolver.Target, cc resolver.Clie...
method Scheme (line 39) | func (d *directBuilder) Scheme() string {
function NewBuilder (line 21) | func NewBuilder() resolver.Builder {
FILE: transport/grpc/resolver/direct/builder_test.go
function TestDirectBuilder_Scheme (line 12) | func TestDirectBuilder_Scheme(t *testing.T) {
type mockConn (line 19) | type mockConn struct
method UpdateState (line 23) | func (m *mockConn) UpdateState(resolver.State) error {
method ReportError (line 30) | func (m *mockConn) ReportError(error) {}
method NewAddress (line 32) | func (m *mockConn) NewAddress(_ []resolver.Address) {}
method NewServiceConfig (line 34) | func (m *mockConn) NewServiceConfig(_ string) {}
method ParseServiceConfig (line 36) | func (m *mockConn) ParseServiceConfig(_ string) *serviceconfig.ParseRe...
function TestDirectBuilder_Build (line 40) | func TestDirectBuilder_Build(t *testing.T) {
FILE: transport/grpc/resolver/direct/resolver.go
type directResolver (line 5) | type directResolver struct
method Close (line 11) | func (r *directResolver) Close() {
method ResolveNow (line 14) | func (r *directResolver) ResolveNow(_ resolver.ResolveNowOptions) {
function newDirectResolver (line 7) | func newDirectResolver() resolver.Resolver {
FILE: transport/grpc/resolver/discovery/builder.go
constant name (line 15) | name = "discovery"
type Option (line 20) | type Option
function WithTimeout (line 23) | func WithTimeout(timeout time.Duration) Option {
function WithInsecure (line 30) | func WithInsecure(insecure bool) Option {
function WithSubset (line 37) | func WithSubset(size int) Option {
function DisableDebugLog (line 45) | func DisableDebugLog() Option {
function PrintDebugLog (line 52) | func PrintDebugLog(p bool) Option {
type builder (line 58) | type builder struct
method Build (line 81) | func (b *builder) Build(target resolver.Target, cc resolver.ClientConn...
method Scheme (line 128) | func (*builder) Scheme() string {
function NewBuilder (line 67) | func NewBuilder(d registry.Discovery, opts ...Option) resolver.Builder {
FILE: transport/grpc/resolver/discovery/builder_test.go
function TestWithInsecure (line 16) | func TestWithInsecure(t *testing.T) {
function TestWithTimeout (line 24) | func TestWithTimeout(t *testing.T) {
function TestDisableDebugLog (line 33) | func TestDisableDebugLog(t *testing.T) {
function TestPrintDebugLog (line 41) | func TestPrintDebugLog(t *testing.T) {
type mockDiscovery (line 49) | type mockDiscovery struct
method GetService (line 51) | func (m *mockDiscovery) GetService(_ context.Context, _ string) ([]*re...
method Watch (line 55) | func (m *mockDiscovery) Watch(_ context.Context, _ string) (registry.W...
function TestBuilder_Scheme (line 60) | func TestBuilder_Scheme(t *testing.T) {
type mockConn (line 67) | type mockConn struct
method UpdateState (line 69) | func (m *mockConn) UpdateState(resolver.State) error {
method ReportError (line 73) | func (m *mockConn) ReportError(error) {}
method NewAddress (line 75) | func (m *mockConn) NewAddress(_ []resolver.Address) {}
method NewServiceConfig (line 77) | func (m *mockConn) NewServiceConfig(_ string) {}
method ParseServiceConfig (line 79) | func (m *mockConn) ParseServiceConfig(_ string) *serviceconfig.ParseRe...
function TestBuilder_Build (line 83) | func TestBuilder_Build(t *testing.T) {
FILE: transport/grpc/resolver/discovery/resolver.go
type discoveryResolver (line 18) | type discoveryResolver struct
method watch (line 31) | func (r *discoveryResolver) watch() {
method update (line 51) | func (r *discoveryResolver) update(ins []*registry.ServiceInstance) {
method Close (line 100) | func (r *discoveryResolver) Close() {
method ResolveNow (line 108) | func (r *discoveryResolver) ResolveNow(_ resolver.ResolveNowOptions) {}
function parseAttributes (line 110) | func parseAttributes(md map[string]string) (a *attributes.Attributes) {
FILE: transport/grpc/resolver/discovery/resolver_test.go
type testClientConn (line 15) | type testClientConn struct
method UpdateState (line 20) | func (t *testClientConn) UpdateState(s resolver.State) error {
type testWatch (line 25) | type testWatch struct
method Next (line 31) | func (m *testWatch) Next() ([]*registry.ServiceInstance, error) {
method Stop (line 55) | func (m *testWatch) Stop() error {
function TestWatch (line 59) | func TestWatch(t *testing.T) {
function TestWatchError (line 78) | func TestWatchError(t *testing.T) {
function TestWatchContextCancel (line 95) | func TestWatchContextCancel(t *testing.T) {
function TestParseAttributes (line 112) | func TestParseAttributes(t *testing.T) {
FILE: transport/grpc/server.go
type ServerOption (line 32) | type ServerOption
function Network (line 35) | func Network(network string) ServerOption {
function Address (line 42) | func Address(addr string) ServerOption {
function Endpoint (line 49) | func Endpoint(endpoint *url.URL) ServerOption {
function Timeout (line 56) | func Timeout(timeout time.Duration) ServerOption {
function Logger (line 64) | func Logger(log.Logger) ServerOption {
function Middleware (line 69) | func Middleware(m ...middleware.Middleware) ServerOption {
function StreamMiddleware (line 75) | func StreamMiddleware(m ...middleware.Middleware) ServerOption {
function CustomHealth (line 82) | func CustomHealth() ServerOption {
function TLSConfig (line 89) | func TLSConfig(c *tls.Config) ServerOption {
function Listener (line 96) | func Listener(lis net.Listener) ServerOption {
function UnaryInterceptor (line 103) | func UnaryInterceptor(in ...grpc.UnaryServerInterceptor) ServerOption {
function StreamInterceptor (line 110) | func StreamInterceptor(in ...grpc.StreamServerInterceptor) ServerOption {
function DisableReflection (line 117) | func DisableReflection() ServerOption {
function Options (line 124) | func Options(opts ...grpc.ServerOption) ServerOption {
type Server (line 131) | type Server struct
method Use (line 210) | func (s *Server) Use(selector string, m ...middleware.Middleware) {
method Endpoint (line 218) | func (s *Server) Endpoint() (*url.URL, error) {
method Start (line 226) | func (s *Server) Start(ctx context.Context) error {
method Stop (line 237) | func (s *Server) Stop(ctx context.Context) error {
method listenAndEndpoint (line 259) | func (s *Server) listenAndEndpoint() error {
function NewServer (line 154) | func NewServer(opts ...ServerOption) *Server {
FILE: transport/grpc/server_test.go
type server (line 28) | type server struct
method SayHelloStream (line 32) | func (s *server) SayHelloStream(streamServer pb.Greeter_SayHelloStream...
method SayHello (line 63) | func (s *server) SayHello(_ context.Context, in *pb.HelloRequest) (*pb...
type testKey (line 73) | type testKey struct
function TestServer (line 75) | func TestServer(t *testing.T) {
function testClient (line 112) | func testClient(t *testing.T, srv *Server) {
function TestNetwork (line 174) | func TestNetwork(t *testing.T) {
function TestAddress (line 183) | func TestAddress(t *testing.T) {
function TestTimeout (line 198) | func TestTimeout(t *testing.T) {
function TestTLSConfig (line 207) | func TestTLSConfig(t *testing.T) {
function TestUnaryInterceptor (line 216) | func TestUnaryInterceptor(t *testing.T) {
function TestStreamInterceptor (line 232) | func TestStreamInterceptor(t *testing.T) {
function TestOptions (line 248) | func TestOptions(t *testing.T) {
type testResp (line 259) | type testResp struct
function TestServer_unaryServerInterceptor (line 263) | func TestServer_unaryServerInterceptor(t *testing.T) {
type mockServerStream (line 287) | type mockServerStream struct
method SetHeader (line 295) | func (m *mockServerStream) SetHeader(md metadata.MD) error {
method SendHeader (line 300) | func (m *mockServerStream) SendHeader(md metadata.MD) error {
method SetTrailer (line 305) | func (m *mockServerStream) SetTrailer(md metadata.MD) {
method Context (line 309) | func (m *mockServerStream) Context() context.Context {
method SendMsg (line 313) | func (m *mockServerStream) SendMsg(msg any) error {
method RecvMsg (line 318) | func (m *mockServerStream) RecvMsg(msg any) error {
function TestServer_streamServerInterceptor (line 323) | func TestServer_streamServerInterceptor(t *testing.T) {
function TestListener (line 363) | func TestListener(t *testing.T) {
function TestStop (line 378) | func TestStop(t *testing.T) {
type safeBytesBuffer (line 485) | type safeBytesBuffer struct
method Write (line 490) | func (b *safeBytesBuffer) Write(p []byte) (n int, err error) {
method String (line 496) | func (b *safeBytesBuffer) String() string {
FILE: transport/grpc/transport.go
type Transport (line 13) | type Transport struct
method Kind (line 22) | func (tr *Transport) Kind() transport.Kind {
method Endpoint (line 27) | func (tr *Transport) Endpoint() string {
method Operation (line 32) | func (tr *Transport) Operation() string {
method RequestHeader (line 37) | func (tr *Transport) RequestHeader() transport.Header {
method ReplyHeader (line 42) | func (tr *Transport) ReplyHeader() transport.Header {
method NodeFilters (line 47) | func (tr *Transport) NodeFilters() []selector.NodeFilter {
type headerCarrier (line 51) | type headerCarrier
method Get (line 54) | func (mc headerCarrier) Get(key string) string {
method Set (line 63) | func (mc headerCarrier) Set(key string, value string) {
method Add (line 68) | func (mc headerCarrier) Add(key string, value string) {
method Keys (line 73) | func (mc headerCarrier) Keys() []string {
method Values (line 82) | func (mc headerCarrier) Values(key string) []string {
FILE: transport/grpc/transport_test.go
function TestTransport_Kind (line 11) | func TestTransport_Kind(t *testing.T) {
function TestTransport_Endpoint (line 18) | func TestTransport_Endpoint(t *testing.T) {
function TestTransport_Operation (line 26) | func TestTransport_Operation(t *testing.T) {
function TestTransport_RequestHeader (line 34) | func TestTransport_RequestHeader(t *testing.T) {
function TestTransport_ReplyHeader (line 46) | func TestTransport_ReplyHeader(t *testing.T) {
function TestHeaderCarrier_Keys (line 55) | func TestHeaderCarrier_Keys(t *testing.T) {
FILE: transport/http/binding/bind.go
function BindQuery (line 13) | func BindQuery(vars url.Values, target any) error {
function BindForm (line 21) | func BindForm(req *http.Request, target any) error {
FILE: transport/http/binding/bind_test.go
type TestBind (line 16) | type TestBind struct
type TestBind2 (line 20) | type TestBind2 struct
function TestBindQuery (line 25) | func TestBindQuery(t *testing.T) {
function TestBindForm (line 77) | func TestBindForm(t *testing.T) {
FILE: transport/http/binding/encode.go
function EncodeURL (line 16) | func EncodeURL(pathTemplate string, msg any, needQuery bool) string {
FILE: transport/http/binding/encode_test.go
function TestEncodeURL (line 11) | func TestEncodeURL(t *testing.T) {
function BenchmarkEncodeURL (line 129) | func BenchmarkEncodeURL(b *testing.B) {
FILE: transport/http/calloption.go
type CallOption (line 9) | type CallOption interface
type callInfo (line 19) | type callInfo struct
type EmptyCallOption (line 29) | type EmptyCallOption struct
method before (line 31) | func (EmptyCallOption) before(*callInfo) error { return nil }
method after (line 32) | func (EmptyCallOption) after(*callInfo, *csAttempt) {}
type csAttempt (line 34) | type csAttempt struct
function ContentType (line 39) | func ContentType(contentType string) CallOption {
type ContentTypeCallOption (line 44) | type ContentTypeCallOption str
Condensed preview — 461 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (2,219K chars).
[
{
"path": ".github/FUNDING.yml",
"chars": 47,
"preview": "open_collective: go-kratos\ngithub: [go-kratos]\n"
},
{
"path": ".github/ISSUE_TEMPLATE/bug-report.md",
"chars": 631,
"preview": "---\nname: \"\\U0001F41B Bug Report\"\nabout: Report something that's broken. Please ensure your kratos version is still supp"
},
{
"path": ".github/ISSUE_TEMPLATE/config.yml",
"chars": 209,
"preview": "blank_issues_enabled: false\ncontact_links:\n - name: Documentation issue\n url: https://go-kratos.dev/docs/\n about:"
},
{
"path": ".github/ISSUE_TEMPLATE/feature-request.md",
"chars": 2503,
"preview": "---\nname: \"\\U0001F4A1 Feature Request\"\nabout: For ideas or feature requests, start a new discussion.\ntitle: \"[Feature]\"\n"
},
{
"path": ".github/ISSUE_TEMPLATE/proposal.md",
"chars": 2695,
"preview": "---\nname: \"\\U0001F9F1 Proposal Request\"\nabout: Implementation draft of feature.\ntitle: \"[Proposal]\"\nlabels: proposal\nass"
},
{
"path": ".github/ISSUE_TEMPLATE/question.md",
"chars": 196,
"preview": "---\nname: \"\\U0001F680 Question\"\nabout: Ask a question about Kratos.\ntitle: \"[Question]\"\nlabels: question\nassignees: ''\n\n"
},
{
"path": ".github/dependabot.yml",
"chars": 123,
"preview": "---\nversion: 2\nupdates:\n - package-ecosystem: \"github-actions\"\n directory: \"/\"\n schedule:\n interval: \"monthl"
},
{
"path": ".github/pull_request_template.md",
"chars": 1909,
"preview": "<!--\n🎉 Thanks for sending a pull request to Kratos! Here are some tips for you:\n\n1. If this is your first time contribut"
},
{
"path": ".github/semantic.yml",
"chars": 373,
"preview": "titleOnly: true\ncommitOnly: false\ntitleAndCommits: false\nscopes:\n - api\n - cmd\n - config\n - contrib\n - docs\n - enc"
},
{
"path": ".github/stable.yml",
"chars": 316,
"preview": "daysUntilStale: 30\ndaysUntilClose: 3\nexemptLabels:\n - pinned\n - security\n - bug\nstaleLabel: wontfix\nmarkComment: >\n "
},
{
"path": ".github/workflows/codeql-analysis.yml",
"chars": 371,
"preview": "name: \"CodeQL\"\n\non:\n push:\n branches: [ main, v1.0.x ]\n\njobs:\n analyze:\n name: Analyze\n runs-on: ubuntu-lates"
},
{
"path": ".github/workflows/comment-check.yml",
"chars": 5806,
"preview": "name: Non-English Comments Check\n\non:\n pull_request_target:\n types: [opened, synchronize, reopened]\n branches:\n "
},
{
"path": ".github/workflows/gitee-sync.yml",
"chars": 607,
"preview": "on:\n push:\n branches:\n - main\n tags:\n - \"*\"\n\nname: Sync to Gitee\njobs:\n run:\n name: Run\n runs-on"
},
{
"path": ".github/workflows/go.yml",
"chars": 2035,
"preview": "name: Go\n\non:\n push:\n branches:\n - main\n pull_request:\n branches:\n - main\n workflow_dispatch:\n\njobs:\n"
},
{
"path": ".github/workflows/issue-translator.yml",
"chars": 442,
"preview": "name: 'issue-translator'\non:\n issue_comment:\n types: [created]\n issues:\n types: [opened]\n\njobs:\n build:\n run"
},
{
"path": ".github/workflows/lint.yml",
"chars": 766,
"preview": "name: Lint\n\non:\n push:\n pull_request:\n branches:\n - main\n workflow_dispatch:\n\njobs:\n resolve-modules:\n na"
},
{
"path": ".gitignore",
"chars": 571,
"preview": "# Reference https://github.com/github/gitignore/blob/master/Go.gitignore\n# Binaries for programs and plugins\n*.exe\n*.exe"
},
{
"path": ".golangci.yml",
"chars": 1148,
"preview": "version: \"2\"\nrun:\n modules-download-mode: readonly\nlinters:\n default: none\n enable:\n - bodyclose\n - dogsled\n "
},
{
"path": "CODE_OF_CONDUCT.md",
"chars": 5218,
"preview": "# Contributor Covenant Code of Conduct\n\n## Our Pledge\n\nWe as members, contributors, and leaders pledge to make participa"
},
{
"path": "CONTRIBUTING.md",
"chars": 4393,
"preview": "The kratos community wants to be helped by a wide range of developers, so you'd like to take a few minutes to read this "
},
{
"path": "LICENSE",
"chars": 1066,
"preview": "MIT License\n\nCopyright (c) 2020 go-kratos\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\n"
},
{
"path": "Makefile",
"chars": 3562,
"preview": "user\t:=\t$(shell whoami)\nrev\t\t:= \t$(shell git rev-parse --short HEAD)\nos\t\t:=\t$(shell uname)\n\n# GOBIN > GOPATH > INSTALLDI"
},
{
"path": "README.md",
"chars": 9718,
"preview": "<p align=\"center\"><a href=\"https://go-kratos.dev/\" target=\"_blank\"><img src=\"https://github.com/go-kratos/kratos/blob/ma"
},
{
"path": "README_zh.md",
"chars": 6073,
"preview": "<p align=\"center\"><a href=\"https://go-kratos.dev/\" target=\"_blank\"><img src=\"https://github.com/go-kratos/kratos/blob/ma"
},
{
"path": "ROADMAP.md",
"chars": 1510,
"preview": "# Kratos\n\nThis document defines the roadmap for Kratos development.\n\n## Features\n- [x] Config\n - [x] Local Files\n "
},
{
"path": "SECURITY.md",
"chars": 569,
"preview": "# Security Policy\n\n## Supported Versions\n\nUse this section to tell people about which versions of your project are\ncurre"
},
{
"path": "api/README.md",
"chars": 12,
"preview": "# API proto\n"
},
{
"path": "api/metadata/metadata.pb.go",
"chars": 13581,
"preview": "// Code generated by protoc-gen-go. DO NOT EDIT.\n// versions:\n// \tprotoc-gen-go v1.28.0\n// \tprotoc v3.19.4\n// sou"
},
{
"path": "api/metadata/metadata.proto",
"chars": 1075,
"preview": "syntax = \"proto3\";\n\npackage kratos.api;\n\nimport \"google/protobuf/descriptor.proto\";\nimport \"google/api/annotations.proto"
},
{
"path": "api/metadata/metadata_grpc.pb.go",
"chars": 5381,
"preview": "// Code generated by protoc-gen-go-grpc. DO NOT EDIT.\n// versions:\n// - protoc-gen-go-grpc v1.2.0\n// - protoc "
},
{
"path": "api/metadata/metadata_http.pb.go",
"chars": 3616,
"preview": "// Code generated by protoc-gen-go-http. DO NOT EDIT.\n// versions:\n// protoc-gen-go-http v2.3.0\n\npackage metadata\n\nimpor"
},
{
"path": "api/metadata/server.go",
"chars": 5542,
"preview": "package metadata\n\nimport (\n\t\"bytes\"\n\t\"compress/gzip\"\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"sort\"\n\t\"sync\"\n\n\t\"google.golang."
},
{
"path": "app.go",
"chars": 4827,
"preview": "package kratos\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"os\"\n\t\"os/signal\"\n\t\"sync\"\n\t\"syscall\"\n\t\"time\"\n\n\t\"github.com/google/uuid\"\n\t"
},
{
"path": "app_test.go",
"chars": 7396,
"preview": "package kratos\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"net/url\"\n\t\"reflect\"\n\t\"sync\"\n\t\"testing\"\n\t\"time\"\n\n\t\"github.com/go-kratos/k"
},
{
"path": "cmd/kratos/go.mod",
"chars": 2220,
"preview": "module github.com/go-kratos/kratos/cmd/kratos/v2\n\ngo 1.23.0\n\ntoolchain go1.24.6\n\nrequire (\n\tgithub.com/AlecAivazis/surve"
},
{
"path": "cmd/kratos/go.sum",
"chars": 14481,
"preview": "github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ=\ngithub.com/AlecAivazis/survey/v2"
},
{
"path": "cmd/kratos/internal/base/install.go",
"chars": 405,
"preview": "package base\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"os/exec\"\n\t\"strings\"\n)\n\n// GoInstall go get path.\nfunc GoInstall(path ...string) er"
},
{
"path": "cmd/kratos/internal/base/mod.go",
"chars": 1525,
"preview": "package base\n\nimport (\n\t\"bufio\"\n\t\"bytes\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"golang.org/x/mod/modfile\"\n)\n\n//"
},
{
"path": "cmd/kratos/internal/base/mod_test.go",
"chars": 750,
"preview": "package base\n\nimport (\n\t\"os\"\n\t\"testing\"\n)\n\nfunc TestModuleVersion(t *testing.T) {\n\tv, err := ModuleVersion(\"golang.org/x"
},
{
"path": "cmd/kratos/internal/base/path.go",
"chars": 2052,
"preview": "package base\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/fatih/color\"\n)\n\nfunc krato"
},
{
"path": "cmd/kratos/internal/base/repo.go",
"chars": 2852,
"preview": "package base\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"net\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path\"\n\t\"path/filepath\"\n\t\"strings\"\n)\n\nvar unExpandVarP"
},
{
"path": "cmd/kratos/internal/base/repo_test.go",
"chars": 1545,
"preview": "package base\n\nimport (\n\t\"context\"\n\t\"os\"\n\t\"testing\"\n)\n\nfunc TestRepo(t *testing.T) {\n\turls := []string{\n\t\t// ssh://[user@"
},
{
"path": "cmd/kratos/internal/base/vcs_url.go",
"chars": 1441,
"preview": "package base\n\nimport (\n\t\"errors\"\n\t\"net/url\"\n\t\"regexp\"\n\t\"strings\"\n)\n\nvar (\n\tscpSyntaxRe = regexp.MustCompile(`^(\\w+)@([\\w"
},
{
"path": "cmd/kratos/internal/base/vcs_url_test.go",
"chars": 1511,
"preview": "package base\n\nimport (\n\t\"net\"\n\t\"strings\"\n\t\"testing\"\n)\n\nfunc TestParseVCSUrl(t *testing.T) {\n\trepos := []string{\n\t\t// ssh"
},
{
"path": "cmd/kratos/internal/change/change.go",
"chars": 989,
"preview": "package change\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\n\t\"github.com/spf13/cobra\"\n)\n\n// CmdChange is kratos change log tool\nvar CmdChange"
},
{
"path": "cmd/kratos/internal/change/get.go",
"chars": 4860,
"preview": "package change\n\nimport (\n\t\"encoding/json\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"os\"\n\t\"regexp\"\n\t\"strings\"\n\t\"time\"\n)\n\ntype "
},
{
"path": "cmd/kratos/internal/change/get_test.go",
"chars": 675,
"preview": "package change\n\nimport \"testing\"\n\nfunc TestParseGithubURL(t *testing.T) {\n\turls := []struct {\n\t\turl string\n\t\towner str"
},
{
"path": "cmd/kratos/internal/project/add.go",
"chars": 1914,
"preview": "package project\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"os\"\n\t\"path/filepath\"\n\n\t\"github.com/AlecAivazis/survey/v2\"\n\t\"github.com/fat"
},
{
"path": "cmd/kratos/internal/project/new.go",
"chars": 1778,
"preview": "package project\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"os\"\n\t\"path/filepath\"\n\n\t\"github.com/AlecAivazis/survey/v2\"\n\t\"github.com/fat"
},
{
"path": "cmd/kratos/internal/project/project.go",
"chars": 5188,
"preview": "package project\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/AlecAivazi"
},
{
"path": "cmd/kratos/internal/project/project_linux_test.go",
"chars": 614,
"preview": "//go:build linux\n\npackage project\n\nimport (\n\t\"testing\"\n)\n\nfunc Test_processProjectParams(t *testing.T) {\n\ttype args stru"
},
{
"path": "cmd/kratos/internal/project/project_test.go",
"chars": 3446,
"preview": "package project\n\nimport (\n\t\"fmt\"\n\t\"go/parser\"\n\t\"go/token\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"testing\"\n\n\t\"github.com/go-kratos/krat"
},
{
"path": "cmd/kratos/internal/project/project_windows_test.go",
"chars": 742,
"preview": "//go:build windows\n\npackage project\n\nimport (\n\t\"testing\"\n)\n\nfunc Test_processProjectParams(t *testing.T) {\n\ttype args st"
},
{
"path": "cmd/kratos/internal/proto/add/add.go",
"chars": 1664,
"preview": "package add\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"strings\"\n\n\t\"github.com/spf13/cobra\"\n\t\"golang.org/x/mod/modfile\"\n\t\"golang.org/x/text"
},
{
"path": "cmd/kratos/internal/proto/add/add_test.go",
"chars": 629,
"preview": "package add\n\nimport \"testing\"\n\nfunc TestUnderscoreToUpperCamelCase(t *testing.T) {\n\ttests := []struct {\n\t\tname string\n\t\t"
},
{
"path": "cmd/kratos/internal/proto/add/proto.go",
"chars": 749,
"preview": "package add\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"path/filepath\"\n)\n\n// Proto is a proto generator.\ntype Proto struct {\n\tName s"
},
{
"path": "cmd/kratos/internal/proto/add/template.go",
"chars": 1326,
"preview": "package add\n\nimport (\n\t\"bytes\"\n\t\"strings\"\n\t\"text/template\"\n)\n\nconst protoTemplate = `\nsyntax = \"proto3\";\n\npackage {{.Pac"
},
{
"path": "cmd/kratos/internal/proto/client/client.go",
"chars": 3098,
"preview": "package client\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path/filepath\"\n\t\"regexp\"\n\t\"strings\"\n\n\t\"github.com/spf13/cobra\"\n\n\t\"git"
},
{
"path": "cmd/kratos/internal/proto/proto.go",
"chars": 545,
"preview": "package proto\n\nimport (\n\t\"github.com/spf13/cobra\"\n\n\t\"github.com/go-kratos/kratos/cmd/kratos/v2/internal/proto/add\"\n\t\"git"
},
{
"path": "cmd/kratos/internal/proto/server/server.go",
"chars": 3044,
"preview": "package server\n\nimport (\n\t\"fmt\"\n\t\"log\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/emicklei/proto\"\n\t\"github.com/spf1"
},
{
"path": "cmd/kratos/internal/proto/server/server_test.go",
"chars": 2453,
"preview": "package server\n\nimport \"testing\"\n\nfunc Test_serviceName(t *testing.T) {\n\ttype args struct {\n\t\tstr string\n\t}\n\ttests := []"
},
{
"path": "cmd/kratos/internal/proto/server/template.go",
"chars": 3326,
"preview": "package server\n\nimport (\n\t\"bytes\"\n\t\"html/template\"\n)\n\n//nolint:lll\nvar serviceTemplate = `\n{{- /* delete empty line */ -"
},
{
"path": "cmd/kratos/internal/run/run.go",
"chars": 3254,
"preview": "package run\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/AlecAivazis/survey/v2\"\n\t\"github."
},
{
"path": "cmd/kratos/internal/upgrade/upgrade.go",
"chars": 840,
"preview": "package upgrade\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/spf13/cobra\"\n\n\t\"github.com/go-kratos/kratos/cmd/kratos/v2/internal/base\"\n"
},
{
"path": "cmd/kratos/main.go",
"chars": 838,
"preview": "package main\n\nimport (\n\t\"log\"\n\n\t\"github.com/spf13/cobra\"\n\n\t\"github.com/go-kratos/kratos/cmd/kratos/v2/internal/change\"\n\t"
},
{
"path": "cmd/kratos/version.go",
"chars": 86,
"preview": "package main\n\n// release is the current kratos tool version.\nconst release = \"v2.9.2\"\n"
},
{
"path": "cmd/protoc-gen-go-errors/buf.gen.yaml",
"chars": 120,
"preview": "version: v2\nplugins:\n - remote: buf.build/protocolbuffers/go:v1.33.0\n out: .\n opt:\n - paths=source_relative\n"
},
{
"path": "cmd/protoc-gen-go-errors/buf.yaml",
"chars": 312,
"preview": "version: v2\nname: buf.build/go-kratos/protoc-gen-go-errors\nlint:\n use:\n - DEFAULT\n except:\n - PACKAGE_DIRECTORY_"
},
{
"path": "cmd/protoc-gen-go-errors/errors/errors.pb.go",
"chars": 8402,
"preview": "// Code generated by protoc-gen-go. DO NOT EDIT.\n// versions:\n// \tprotoc-gen-go v1.26.0\n// \tprotoc v3.15.7\n// sou"
},
{
"path": "cmd/protoc-gen-go-errors/errors/errors.proto",
"chars": 529,
"preview": "syntax = \"proto3\";\n\npackage errors;\n\noption go_package = \"github.com/go-kratos/kratos/v2/errors;errors\";\noption java_mul"
},
{
"path": "cmd/protoc-gen-go-errors/errors.go",
"chars": 3628,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"unicode\"\n\n\t\"golang.org/x/text/cases\"\n\t\"golang.org/x/text/language\"\n\n\t\"google."
},
{
"path": "cmd/protoc-gen-go-errors/errorsTemplate.tpl",
"chars": 496,
"preview": "{{ range .Errors }}\n\n{{ if .HasComment }}{{ .Comment }}{{ end -}}\nfunc Is{{.CamelValue}}(err error) bool {\n\tif err == ni"
},
{
"path": "cmd/protoc-gen-go-errors/errors_test.go",
"chars": 1010,
"preview": "package main\n\nimport \"testing\"\n\nfunc Test_case2Camel(t *testing.T) {\n\ttype args struct {\n\t\tname string\n\t}\n\ttests := []st"
},
{
"path": "cmd/protoc-gen-go-errors/go.mod",
"chars": 147,
"preview": "module github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2\n\ngo 1.22\n\nrequire (\n\tgolang.org/x/text v0.3.8\n\tgoogle.gol"
},
{
"path": "cmd/protoc-gen-go-errors/go.sum",
"chars": 708,
"preview": "github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=\ngithub.com/google/go-cmp v0.5.5/go.mod h"
},
{
"path": "cmd/protoc-gen-go-errors/main.go",
"chars": 637,
"preview": "package main\n\nimport (\n\t\"flag\"\n\t\"fmt\"\n\n\t\"google.golang.org/protobuf/compiler/protogen\"\n\t\"google.golang.org/protobuf/type"
},
{
"path": "cmd/protoc-gen-go-errors/template.go",
"chars": 552,
"preview": "package main\n\nimport (\n\t\"bytes\"\n\t_ \"embed\"\n\t\"text/template\"\n)\n\n//go:embed errorsTemplate.tpl\nvar errorsTemplate string\n\n"
},
{
"path": "cmd/protoc-gen-go-errors/version.go",
"chars": 95,
"preview": "package main\n\n// release is the current protoc-gen-go-errors version.\nconst release = \"v2.9.2\"\n"
},
{
"path": "cmd/protoc-gen-go-http/go.mod",
"chars": 182,
"preview": "module github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2\n\ngo 1.22\n\nrequire (\n\tgoogle.golang.org/genproto v0.0.0-2022"
},
{
"path": "cmd/protoc-gen-go-http/go.sum",
"chars": 13178,
"preview": "cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=\ncloud.google.com/go v0.34.0/go.mod h1"
},
{
"path": "cmd/protoc-gen-go-http/http.go",
"chars": 10493,
"preview": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"os\"\n\t\"regexp\"\n\t\"strings\"\n\n\t\"google.golang.org/protobuf/reflect/protoreflect\""
},
{
"path": "cmd/protoc-gen-go-http/httpTemplate.tpl",
"chars": 2553,
"preview": "{{$svrType := .ServiceType}}\n{{$svrName := .ServiceName}}\n\n{{- range .MethodSets}}\nconst Operation{{$svrType}}{{.Origina"
},
{
"path": "cmd/protoc-gen-go-http/http_test.go",
"chars": 3007,
"preview": "package main\n\nimport (\n\t\"reflect\"\n\t\"testing\"\n)\n\nfunc TestNoParameters(t *testing.T) {\n\tpath := \"/test/noparams\"\n\tm := bu"
},
{
"path": "cmd/protoc-gen-go-http/main.go",
"chars": 826,
"preview": "package main\n\nimport (\n\t\"flag\"\n\t\"fmt\"\n\n\t\"google.golang.org/protobuf/compiler/protogen\"\n\t\"google.golang.org/protobuf/type"
},
{
"path": "cmd/protoc-gen-go-http/template.go",
"chars": 1060,
"preview": "package main\n\nimport (\n\t\"bytes\"\n\t_ \"embed\"\n\t\"strings\"\n\t\"text/template\"\n)\n\n//go:embed httpTemplate.tpl\nvar httpTemplate s"
},
{
"path": "cmd/protoc-gen-go-http/version.go",
"chars": 93,
"preview": "package main\n\n// release is the current protoc-gen-go-http version.\nconst release = \"v2.9.2\"\n"
},
{
"path": "codecov.yml",
"chars": 40,
"preview": "ignore:\n - \"examples\"\n - \"**/*.pb.go\"\n"
},
{
"path": "config/README.md",
"chars": 363,
"preview": "# Config\n\n## kubernetes\n\n```shell\ngo get -u github.com/go-kratos/kratos/contrib/config/kubernetes/v2\n```\n\n## apollo\n\n```"
},
{
"path": "config/config.go",
"chars": 3899,
"preview": "package config\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"reflect\"\n\t\"sync\"\n\t\"time\"\n\n\t\"dario.cat/mergo\"\n\n\t// init encoding\n\t_ \"gith"
},
{
"path": "config/config_test.go",
"chars": 4566,
"preview": "package config\n\nimport (\n\t\"errors\"\n\t\"testing\"\n\n\t\"dario.cat/mergo\"\n)\n\nconst (\n\t_testJSON = `\n{\n \"server\":{\n \"ht"
},
{
"path": "config/env/env.go",
"chars": 1090,
"preview": "package env\n\nimport (\n\t\"os\"\n\t\"strings\"\n\n\t\"github.com/go-kratos/kratos/v2/config\"\n)\n\ntype env struct {\n\tprefixes []string"
},
{
"path": "config/env/env_test.go",
"chars": 9426,
"preview": "package env\n\nimport (\n\t\"os\"\n\t\"path/filepath\"\n\t\"reflect\"\n\t\"testing\"\n\n\t\"github.com/go-kratos/kratos/v2/config\"\n\t\"github.co"
},
{
"path": "config/env/watcher.go",
"chars": 560,
"preview": "package env\n\nimport (\n\t\"context\"\n\n\t\"github.com/go-kratos/kratos/v2/config\"\n)\n\nvar _ config.Watcher = (*watcher)(nil)\n\nty"
},
{
"path": "config/env/watcher_test.go",
"chars": 570,
"preview": "package env\n\nimport (\n\t\"testing\"\n)\n\nfunc Test_watcher_next(t *testing.T) {\n\tt.Run(\"next after stop should return err\", f"
},
{
"path": "config/file/file.go",
"chars": 1440,
"preview": "package file\n\nimport (\n\t\"io\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/go-kratos/kratos/v2/config\"\n)\n\nvar _ config"
},
{
"path": "config/file/file_test.go",
"chars": 7580,
"preview": "package file\n\nimport (\n\t\"errors\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"reflect\"\n\t\"sync\"\n\t\"testing\"\n\t\"time\"\n\n\t\"github.com/go-kratos/kr"
},
{
"path": "config/file/format.go",
"chars": 160,
"preview": "package file\n\nimport \"strings\"\n\nfunc format(name string) string {\n\tif idx := strings.LastIndexByte(name, '.'); idx >= 0 "
},
{
"path": "config/file/format_test.go",
"chars": 709,
"preview": "package file\n\nimport (\n\t\"testing\"\n)\n\nfunc TestFormat(t *testing.T) {\n\ttests := []struct {\n\t\tinput string\n\t\texpect strin"
},
{
"path": "config/file/watcher.go",
"chars": 1326,
"preview": "package file\n\nimport (\n\t\"context\"\n\t\"os\"\n\t\"path/filepath\"\n\n\t\"github.com/fsnotify/fsnotify\"\n\n\t\"github.com/go-kratos/kratos"
},
{
"path": "config/options.go",
"chars": 4826,
"preview": "package config\n\nimport (\n\t\"fmt\"\n\t\"regexp\"\n\t\"strconv\"\n\t\"strings\"\n\n\t\"github.com/go-kratos/kratos/v2/encoding\"\n)\n\n// Decode"
},
{
"path": "config/options_test.go",
"chars": 8393,
"preview": "package config\n\nimport (\n\t\"reflect\"\n\t\"strings\"\n\t\"testing\"\n)\n\nfunc TestDefaultDecoder(t *testing.T) {\n\tsrc := &KeyValue{\n"
},
{
"path": "config/reader.go",
"chars": 3587,
"preview": "package config\n\nimport (\n\t\"bytes\"\n\t\"encoding/gob\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"strings\"\n\t\"sync\"\n\n\t\"google.golang.org/protob"
},
{
"path": "config/reader_test.go",
"chars": 6021,
"preview": "package config\n\nimport (\n\t\"fmt\"\n\t\"reflect\"\n\t\"testing\"\n\n\t\"github.com/go-kratos/kratos/v2/encoding\"\n\n\t\"dario.cat/mergo\"\n)\n"
},
{
"path": "config/source.go",
"chars": 341,
"preview": "package config\n\n// KeyValue is config key value.\ntype KeyValue struct {\n\tKey string\n\tValue []byte\n\tFormat string\n}\n\n"
},
{
"path": "config/value.go",
"chars": 4404,
"preview": "package config\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"reflect\"\n\t\"strconv\"\n\t\"sync/atomic\"\n\t\"time\"\n\n\t\"google.golang.org/proto"
},
{
"path": "config/value_test.go",
"chars": 3836,
"preview": "package config\n\nimport (\n\t\"fmt\"\n\t\"testing\"\n\t\"time\"\n)\n\nfunc TestAtomicValue_Bool(t *testing.T) {\n\tvlist := []any{\"1\", \"t\""
},
{
"path": "contrib/config/apollo/README.md",
"chars": 2190,
"preview": "## Apollo config center\n\nThis module implements the `config.Source` interface in kratos based apollo config management c"
},
{
"path": "contrib/config/apollo/apollo.go",
"chars": 6420,
"preview": "package apollo\n\nimport (\n\t\"strings\"\n\n\t\"github.com/apolloconfig/agollo/v4\"\n\t\"github.com/apolloconfig/agollo/v4/constant\"\n"
},
{
"path": "contrib/config/apollo/apollo_test.go",
"chars": 1548,
"preview": "package apollo\n\nimport (\n\t\"testing\"\n)\n\nfunc Test_genKey(t *testing.T) {\n\ttype args struct {\n\t\tns string\n\t\tsub string\n\t}"
},
{
"path": "contrib/config/apollo/go.mod",
"chars": 1084,
"preview": "module github.com/go-kratos/kratos/contrib/config/apollo/v2\n\ngo 1.22\n\nrequire (\n\tgithub.com/apolloconfig/agollo/v4 v4.3."
},
{
"path": "contrib/config/apollo/go.sum",
"chars": 62208,
"preview": "cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=\ncloud.google.com/go v0.34.0/go.mod h1"
},
{
"path": "contrib/config/apollo/parser.go",
"chars": 345,
"preview": "package apollo\n\ntype jsonExtParser struct{}\n\nfunc (parser jsonExtParser) Parse(configContent any) (map[string]any, error"
},
{
"path": "contrib/config/apollo/watcher.go",
"chars": 2344,
"preview": "package apollo\n\nimport (\n\t\"context\"\n\t\"strings\"\n\n\t\"github.com/apolloconfig/agollo/v4/storage\"\n\n\t\"github.com/go-kratos/kra"
},
{
"path": "contrib/config/apollo/watcher_test.go",
"chars": 1611,
"preview": "package apollo\n\nimport (\n\t\"testing\"\n\n\t\"github.com/apolloconfig/agollo/v4/storage\"\n\n\t\"github.com/go-kratos/kratos/v2/conf"
},
{
"path": "contrib/config/consul/README.md",
"chars": 612,
"preview": "# Consul Config\n\n```go\nimport (\n \"github.com/hashicorp/consul/api\"\n\n \"github.com/go-kratos/kratos/contrib/config/c"
},
{
"path": "contrib/config/consul/config.go",
"chars": 1596,
"preview": "package consul\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/hashicorp/consul/api\"\n\n\t\"github."
},
{
"path": "contrib/config/consul/config_test.go",
"chars": 5073,
"preview": "package consul\n\nimport (\n\t\"reflect\"\n\t\"testing\"\n\t\"time\"\n\n\t\"github.com/hashicorp/consul/api\"\n\n\t\"github.com/go-kratos/krato"
},
{
"path": "contrib/config/consul/go.mod",
"chars": 1170,
"preview": "module github.com/go-kratos/kratos/contrib/config/consul/v2\n\ngo 1.22\n\nrequire (\n\tgithub.com/go-kratos/kratos/v2 v2.9.2\n\t"
},
{
"path": "contrib/config/consul/go.sum",
"chars": 22719,
"preview": "dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=\ndario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobSt"
},
{
"path": "contrib/config/consul/watcher.go",
"chars": 2024,
"preview": "package consul\n\nimport (\n\t\"context\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/hashicorp/consul/api\"\n\t\"github.com/hashico"
},
{
"path": "contrib/config/etcd/README.md",
"chars": 924,
"preview": "# Etcd Config\n\n```go\nimport (\n\t\"log\"\n\n\tclientv3 \"go.etcd.io/etcd/client/v3\"\n\t\"google.golang.org/grpc\"\n\n\tcfg \"github.com/"
},
{
"path": "contrib/config/etcd/config.go",
"chars": 1735,
"preview": "package etcd\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\tclientv3 \"go.etcd.io/etcd/client/v3\"\n\n\t\"github"
},
{
"path": "contrib/config/etcd/config_test.go",
"chars": 3213,
"preview": "package etcd\n\nimport (\n\t\"context\"\n\t\"reflect\"\n\t\"testing\"\n\t\"time\"\n\n\tclientv3 \"go.etcd.io/etcd/client/v3\"\n\t\"google.golang.o"
},
{
"path": "contrib/config/etcd/go.mod",
"chars": 1188,
"preview": "module github.com/go-kratos/kratos/contrib/config/etcd/v2\n\ngo 1.22\n\nrequire (\n\tgithub.com/go-kratos/kratos/v2 v2.9.2\n\tgo"
},
{
"path": "contrib/config/etcd/go.sum",
"chars": 9260,
"preview": "dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=\ndario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobSt"
},
{
"path": "contrib/config/etcd/watcher.go",
"chars": 862,
"preview": "package etcd\n\nimport (\n\t\"context\"\n\n\tclientv3 \"go.etcd.io/etcd/client/v3\"\n\n\t\"github.com/go-kratos/kratos/v2/config\"\n)\n\nty"
},
{
"path": "contrib/config/kubernetes/README.md",
"chars": 907,
"preview": "# Kubernetes Config\n\n### Usage in the Kubernetes Cluster\nIt is required to\n> serviceaccount should be set to the actual "
},
{
"path": "contrib/config/kubernetes/config.go",
"chars": 3001,
"preview": "package kubernetes\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\tv1 \"k8s.io/api/core/v1\"\n\tmetav1 \""
},
{
"path": "contrib/config/kubernetes/config_test.go",
"chars": 4389,
"preview": "package kubernetes\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"path/filepath\"\n\t\"reflect\"\n\t\"strings\"\n\t\"testing\"\n\n\tv1 \"k8s.io/api/core/v"
},
{
"path": "contrib/config/kubernetes/go.mod",
"chars": 2100,
"preview": "module github.com/go-kratos/kratos/contrib/config/kubernetes/v2\n\ngo 1.22\n\nrequire (\n\tgithub.com/go-kratos/kratos/v2 v2.9"
},
{
"path": "contrib/config/kubernetes/go.sum",
"chars": 48063,
"preview": "cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=\ncloud.google.com/go v0.34.0/go.mod h1"
},
{
"path": "contrib/config/kubernetes/watcher.go",
"chars": 1349,
"preview": "package kubernetes\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\n\tv1 \"k8s.io/api/core/v1\"\n\tmetav1 \"k8s.io/apimachinery/pkg/apis/meta/v1\"\n"
},
{
"path": "contrib/config/kubernetes/watcher_test.go",
"chars": 870,
"preview": "package kubernetes\n\nimport (\n\t\"context\"\n\t\"path/filepath\"\n\t\"testing\"\n\t\"time\"\n\n\tmetav1 \"k8s.io/apimachinery/pkg/apis/meta/"
},
{
"path": "contrib/config/nacos/README.md",
"chars": 764,
"preview": "# Nacos Config\n\n```go\nimport (\n\t\"github.com/nacos-group/nacos-sdk-go/clients\"\n\t\"github.com/nacos-group/nacos-sdk-go/comm"
},
{
"path": "contrib/config/nacos/config.go",
"chars": 1661,
"preview": "package config\n\nimport (\n\t\"context\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/nacos-group/nacos-sdk-go/clients/config_cl"
},
{
"path": "contrib/config/nacos/config_test.go",
"chars": 4914,
"preview": "package config\n\nimport (\n\t\"reflect\"\n\t\"testing\"\n\t\"time\"\n\n\t\"github.com/nacos-group/nacos-sdk-go/clients\"\n\t\"github.com/naco"
},
{
"path": "contrib/config/nacos/go.mod",
"chars": 1236,
"preview": "module github.com/go-kratos/kratos/contrib/config/nacos/v2\n\ngo 1.22\n\nrequire (\n\tgithub.com/go-kratos/kratos/v2 v2.9.2\n\tg"
},
{
"path": "contrib/config/nacos/go.sum",
"chars": 11941,
"preview": "dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=\ndario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobSt"
},
{
"path": "contrib/config/nacos/watcher.go",
"chars": 1314,
"preview": "package config\n\nimport (\n\t\"context\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/nacos-group/nacos-sdk-go/vo\"\n\n\t\"github.com"
},
{
"path": "contrib/config/polaris/README.md",
"chars": 436,
"preview": "# Polaris Config\n\n```go\nimport (\n\t\"log\"\n\n\t\"github.com/polarismesh/polaris-go\"\n\n\t\"github.com/go-kratos/kratos/contrib/con"
},
{
"path": "contrib/config/polaris/config.go",
"chars": 1924,
"preview": "package config\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/polarismesh/polaris-go\"\n\n\t\"github.co"
},
{
"path": "contrib/config/polaris/go.mod",
"chars": 1580,
"preview": "module github.com/go-kratos/kratos/contrib/config/polaris/v2\n\ngo 1.22\n\nrequire (\n\tgithub.com/go-kratos/kratos/v2 v2.9.2\n"
},
{
"path": "contrib/config/polaris/go.sum",
"chars": 58148,
"preview": "cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=\ncloud.google.com/go v0.34.0/go.mod h1"
},
{
"path": "contrib/config/polaris/polaris.yaml",
"chars": 130,
"preview": "global:\n serverConnector:\n addresses:\n - 127.0.0.1:8091\nconfig:\n configConnector:\n addresses:\n - 127.0"
},
{
"path": "contrib/config/polaris/watcher.go",
"chars": 1764,
"preview": "package config\n\nimport (\n\t\"fmt\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/polarismesh/polaris-go\"\n\t\"github.com/polarisme"
},
{
"path": "contrib/encoding/msgpack/go.mod",
"chars": 283,
"preview": "module github.com/go-kratos/kratos/contrib/encoding/msgpack/v2\n\ngo 1.22\n\nrequire (\n\tgithub.com/go-kratos/kratos/v2 v2.9."
},
{
"path": "contrib/encoding/msgpack/go.sum",
"chars": 1046,
"preview": "github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=\ngithub.com/davecgh/go-spew v1.1.0/go.m"
},
{
"path": "contrib/encoding/msgpack/msgpack.go",
"chars": 522,
"preview": "package msgpack\n\nimport (\n\t\"github.com/vmihailenco/msgpack/v5\"\n\n\t\"github.com/go-kratos/kratos/v2/encoding\"\n)\n\n// Name is"
},
{
"path": "contrib/encoding/msgpack/msgpack_test.go",
"chars": 1424,
"preview": "package msgpack\n\nimport (\n\t\"reflect\"\n\t\"testing\"\n)\n\ntype loginRequest struct {\n\tUserName string\n\tPassword string\n}\n\ntype "
},
{
"path": "contrib/errortracker/sentry/README.md",
"chars": 1713,
"preview": "# Sentry middleware for Kratos\nThis middleware helps you to catch panics and report them to [sentry](https://sentry.io/)"
},
{
"path": "contrib/errortracker/sentry/go.mod",
"chars": 1004,
"preview": "module github.com/go-kratos/kratos/contrib/errortracker/sentry/v2\n\ngo 1.22\n\nrequire (\n\tgithub.com/getsentry/sentry-go v0"
},
{
"path": "contrib/errortracker/sentry/go.sum",
"chars": 6052,
"preview": "github.com/census-instrumentation/opencensus-proto v0.4.1 h1:iKLQ0xPNFxR/2hzXZMrBo8f1j86j5WHzznCCQxV/b8g=\ngithub.com/cen"
},
{
"path": "contrib/errortracker/sentry/sentry.go",
"chars": 3705,
"preview": "package sentry\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"net\"\n\t\"os\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/getsentry/sentry-go\"\n\n\t\"github."
},
{
"path": "contrib/errortracker/sentry/sentry_test.go",
"chars": 987,
"preview": "package sentry\n\nimport (\n\t\"testing\"\n\t\"time\"\n)\n\nfunc TestWithTags(t *testing.T) {\n\topts := new(options)\n\tstrval := \"bar\"\n"
},
{
"path": "contrib/log/aliyun/aliyun.go",
"chars": 3610,
"preview": "package aliyun\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"strconv\"\n\t\"time\"\n\n\tsls \"github.com/aliyun/aliyun-log-go-sdk\"\n\t\"github"
},
{
"path": "contrib/log/aliyun/aliyun_test.go",
"chars": 4289,
"preview": "package aliyun\n\nimport (\n\t\"math\"\n\t\"reflect\"\n\t\"testing\"\n\n\t\"github.com/go-kratos/kratos/v2/log\"\n)\n\nfunc TestWithEndpoint(t"
},
{
"path": "contrib/log/aliyun/go.mod",
"chars": 779,
"preview": "module github.com/go-kratos/kratos/contrib/log/aliyun/v2\n\ngo 1.22\n\nrequire (\n\tgithub.com/aliyun/aliyun-log-go-sdk v0.1.9"
},
{
"path": "contrib/log/aliyun/go.sum",
"chars": 42748,
"preview": "cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=\ncloud.google.com/go v0.34.0/go.mod h1"
},
{
"path": "contrib/log/fluent/fluent.go",
"chars": 3798,
"preview": "package fluent\n\nimport (\n\t\"fmt\"\n\t\"net\"\n\t\"net/url\"\n\t\"strconv\"\n\t\"time\"\n\n\t\"github.com/fluent/fluent-logger-golang/fluent\"\n\n"
},
{
"path": "contrib/log/fluent/fluent_test.go",
"chars": 5336,
"preview": "package fluent\n\nimport (\n\t\"io\"\n\t\"net\"\n\t\"os\"\n\t\"testing\"\n\t\"time\"\n\n\t\"github.com/go-kratos/kratos/v2/log\"\n)\n\nfunc TestMain(m"
},
{
"path": "contrib/log/fluent/go.mod",
"chars": 435,
"preview": "module github.com/go-kratos/kratos/contrib/log/fluent/v2\n\ngo 1.22\n\nrequire (\n\tgithub.com/fluent/fluent-logger-golang v1."
},
{
"path": "contrib/log/fluent/go.sum",
"chars": 3666,
"preview": "github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4YnC6+E63dPcxHo2sUxDIu8g3QgEJdRY=\ngithub.co"
},
{
"path": "contrib/log/logrus/go.mod",
"chars": 252,
"preview": "module github.com/go-kratos/kratos/contrib/log/logrus/v2\n\ngo 1.22\n\nrequire (\n\tgithub.com/go-kratos/kratos/v2 v2.9.2\n\tgit"
},
{
"path": "contrib/log/logrus/go.sum",
"chars": 1107,
"preview": "github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=\ngithub.com/davecgh/go-spew v1.1.1/go.m"
},
{
"path": "contrib/log/logrus/logrus.go",
"chars": 1270,
"preview": "package logrus\n\nimport (\n\t\"github.com/sirupsen/logrus\"\n\n\t\"github.com/go-kratos/kratos/v2/log\"\n)\n\nvar _ log.Logger = (*Lo"
},
{
"path": "contrib/log/logrus/logrus_test.go",
"chars": 1653,
"preview": "package logrus\n\nimport (\n\t\"bytes\"\n\t\"strings\"\n\t\"testing\"\n\n\t\"github.com/sirupsen/logrus\"\n\n\t\"github.com/go-kratos/kratos/v2"
},
{
"path": "contrib/log/tencent/go.mod",
"chars": 470,
"preview": "module github.com/go-kratos/kratos/contrib/log/tencent/v2\n\ngo 1.22\n\nrequire (\n\tgithub.com/go-kratos/kratos/v2 v2.9.2\n\tgi"
},
{
"path": "contrib/log/tencent/go.sum",
"chars": 4044,
"preview": "github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=\ngithub.com/davecgh/go-spew v1.1.0/go"
},
{
"path": "contrib/log/tencent/tencent.go",
"chars": 3262,
"preview": "package tencent\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"strconv\"\n\t\"time\"\n\n\tcls \"github.com/tencentcloud/tencentcloud-cls-sdk"
},
{
"path": "contrib/log/tencent/tencent_test.go",
"chars": 4119,
"preview": "package tencent\n\nimport (\n\t\"math\"\n\t\"reflect\"\n\t\"testing\"\n\n\t\"github.com/go-kratos/kratos/v2/log\"\n)\n\nfunc TestWithEndpoint("
},
{
"path": "contrib/log/zap/go.mod",
"chars": 243,
"preview": "module github.com/go-kratos/kratos/contrib/log/zap/v2\n\ngo 1.22\n\nrequire (\n\tgithub.com/go-kratos/kratos/v2 v2.9.2\n\tgo.ube"
},
{
"path": "contrib/log/zap/go.sum",
"chars": 1294,
"preview": "github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=\ngithub.com/davecgh/go-spew v1.1.1/go.m"
},
{
"path": "contrib/log/zap/zap.go",
"chars": 1549,
"preview": "package zap\n\nimport (\n\t\"fmt\"\n\n\t\"go.uber.org/zap\"\n\t\"go.uber.org/zap/zapcore\"\n\n\t\"github.com/go-kratos/kratos/v2/log\"\n)\n\nva"
},
{
"path": "contrib/log/zap/zap_test.go",
"chars": 1683,
"preview": "package zap\n\nimport (\n\t\"testing\"\n\n\t\"go.uber.org/zap\"\n\t\"go.uber.org/zap/zapcore\"\n\n\t\"github.com/go-kratos/kratos/v2/log\"\n)"
},
{
"path": "contrib/log/zerolog/go.mod",
"chars": 353,
"preview": "module github.com/go-kratos/kratos/contrib/log/zerolog/v2\n\ngo 1.22\n\nrequire (\n\tgithub.com/go-kratos/kratos/v2 v2.9.2\n\tgi"
},
{
"path": "contrib/log/zerolog/go.sum",
"chars": 1385,
"preview": "github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=\ngithub.com/godbus/dbus/v"
},
{
"path": "contrib/log/zerolog/zerolog.go",
"chars": 905,
"preview": "package zerolog\n\nimport (\n\t\"github.com/rs/zerolog\"\n\n\t\"github.com/go-kratos/kratos/v2/log\"\n)\n\nvar _ log.Logger = (*Logger"
},
{
"path": "contrib/log/zerolog/zerolog_test.go",
"chars": 943,
"preview": "package zerolog\n\nimport (\n\t\"testing\"\n\n\t\"github.com/rs/zerolog\"\n\n\t\"github.com/go-kratos/kratos/v2/log\"\n)\n\ntype testWriteS"
},
{
"path": "contrib/middleware/validate/README.md",
"chars": 1045,
"preview": "# Validator Middleware for Kratos Project\n\nThis module provides a middleware for Kratos to validate request parameters, "
},
{
"path": "contrib/middleware/validate/go.mod",
"chars": 982,
"preview": "module github.com/go-kratos/kratos/contrib/middleware/validate/v2\n\ngo 1.23.0\n\ntoolchain go1.24.6\n\nrequire (\n\tbuf.build/g"
},
{
"path": "contrib/middleware/validate/go.sum",
"chars": 4537,
"preview": "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.6-20250717165733-d22d418d82d8.1 h1:VahIvw/JagkamVOb0q87"
},
{
"path": "contrib/middleware/validate/internal/testdata/generate.go",
"chars": 167,
"preview": "package testdata\n\n//go:generate protoc -I . -I ../../../../../third_party --go_out=paths=source_relative:. --validate_ou"
},
{
"path": "contrib/middleware/validate/internal/testdata/test.pb.go",
"chars": 8203,
"preview": "// Code generated by protoc-gen-go. DO NOT EDIT.\n// versions:\n// \tprotoc-gen-go v1.36.4\n// \tprotoc v5.29.3\n// sou"
},
{
"path": "contrib/middleware/validate/internal/testdata/test.pb.validate.go",
"chars": 8852,
"preview": "// Code generated by protoc-gen-validate. DO NOT EDIT.\n// source: test.proto\n\npackage testdata\n\nimport (\n\t\"bytes\"\n\t\"erro"
},
{
"path": "contrib/middleware/validate/internal/testdata/test.proto",
"chars": 601,
"preview": "syntax = \"proto3\";\n\npackage testdata;\n\nimport \"buf/validate/validate.proto\";\nimport \"validate/validate.proto\";\n\noption g"
},
{
"path": "contrib/middleware/validate/validate.go",
"chars": 1037,
"preview": "package validate\n\nimport (\n\t\"context\"\n\n\t\"github.com/go-kratos/kratos/v2/errors\"\n\t\"github.com/go-kratos/kratos/v2/middlew"
},
{
"path": "contrib/middleware/validate/validate_test.go",
"chars": 1759,
"preview": "package validate\n\nimport (\n\t\"context\"\n\t\"testing\"\n\n\t\"google.golang.org/protobuf/proto\"\n\n\t\"github.com/go-kratos/kratos/con"
},
{
"path": "contrib/opensergo/README.md",
"chars": 492,
"preview": "# OpenSergo\n\n## Usage\n\n```go\nosServer, err := opensergo.New(opensergo.WithEndpoint(\"localhost:9090\"))\nif err != nil {\n\tp"
},
{
"path": "contrib/opensergo/go.mod",
"chars": 934,
"preview": "module github.com/go-kratos/kratos/contrib/opensergo/v2\n\ngo 1.22\n\nrequire (\n\tgithub.com/go-kratos/kratos/v2 v2.9.2\n\tgith"
},
{
"path": "contrib/opensergo/go.sum",
"chars": 15194,
"preview": "cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=\ncloud.google.com/go v0.34.0/go.mod h1"
},
{
"path": "contrib/opensergo/opensergo.go",
"chars": 5326,
"preview": "package opensergo\n\nimport (\n\t\"context\"\n\t\"encoding/json\"\n\t\"net\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"os\"\n\t\"strconv\"\n\t\"time\"\n\n\tv1 \"git"
},
{
"path": "contrib/opensergo/opensergo_test.go",
"chars": 8855,
"preview": "package opensergo\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"net/http\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"reflect\"\n\t\"testing\"\n\n\tsrvContractPb \""
},
{
"path": "contrib/polaris/config.go",
"chars": 2882,
"preview": "package polaris\n\nimport (\n\t\"context\"\n\t\"path/filepath\"\n\t\"strings\"\n\n\t\"github.com/polarismesh/polaris-go\"\n\t\"github.com/pola"
},
{
"path": "contrib/polaris/config_test.go",
"chars": 8664,
"preview": "package polaris\n\nimport (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"reflect\"\n\t\"strings\"\n\t\"testing\"\n\t\"time\"\n\n\t\"github.c"
},
{
"path": "contrib/polaris/go.mod",
"chars": 1742,
"preview": "module github.com/go-kratos/kratos/contrib/polaris/v2\n\ngo 1.23.0\n\ntoolchain go1.24.6\n\nrequire (\n\tgithub.com/go-kratos/ae"
},
{
"path": "contrib/polaris/go.sum",
"chars": 59362,
"preview": "cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=\ncloud.google.com/go v0.34.0/go.mod h1"
},
{
"path": "contrib/polaris/limiter.go",
"chars": 2420,
"preview": "package polaris\n\nimport (\n\t\"time\"\n\n\t\"github.com/go-kratos/aegis/ratelimit\"\n\n\t\"github.com/polarismesh/polaris-go\"\n\t\"githu"
},
{
"path": "contrib/polaris/polaris.go",
"chars": 2003,
"preview": "package polaris\n\nimport (\n\t\"errors\"\n\n\t\"github.com/polarismesh/polaris-go\"\n\t\"github.com/polarismesh/polaris-go/api\"\n\n\t\"gi"
},
{
"path": "contrib/polaris/ratelimit.go",
"chars": 1481,
"preview": "package polaris\n\nimport (\n\t\"context\"\n\t\"strings\"\n\n\t\"github.com/go-kratos/aegis/ratelimit\"\n\n\t\"github.com/go-kratos/kratos/"
},
{
"path": "contrib/polaris/registry.go",
"chars": 11061,
"preview": "package polaris\n\nimport (\n\t\"context\"\n\t\"net\"\n\t\"net/url\"\n\t\"strconv\"\n\t\"time\"\n\n\t\"github.com/google/uuid\"\n\t\"github.com/polari"
}
]
// ... and 261 more files (download for full content)
About this extraction
This page contains the full source code of the go-kratos/kratos GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 461 files (2.0 MB), approximately 534.9k tokens, and a symbol index with 2765 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.