Skip to content

Commit 25821bd

Browse files
authored
chore: coding style (#3960)
1 parent b624b96 commit 25821bd

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

core/stores/mon/options.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ var (
1919
)
2020

2121
type (
22-
options = mopt.ClientOptions
23-
2422
// Option defines the method to customize a mongo model.
2523
Option func(opts *options)
2624

27-
// RegisterType A struct store With custom type and Encoder/Decoder
28-
RegisterType struct {
25+
// TypeCodec is a struct that stores specific type Encoder/Decoder.
26+
TypeCodec struct {
2927
ValueType reflect.Type
3028
Encoder bsoncodec.ValueEncoder
3129
Decoder bsoncodec.ValueDecoder
3230
}
31+
32+
options = mopt.ClientOptions
3333
)
3434

3535
// DisableLog disables logging of mongo commands, includes info and slow logs.
@@ -48,27 +48,27 @@ func SetSlowThreshold(threshold time.Duration) {
4848
slowThreshold.Set(threshold)
4949
}
5050

51-
func defaultTimeoutOption() Option {
52-
return func(opts *options) {
53-
opts.SetTimeout(defaultTimeout)
54-
}
55-
}
56-
5751
// WithTimeout set the mon client operation timeout.
5852
func WithTimeout(timeout time.Duration) Option {
5953
return func(opts *options) {
6054
opts.SetTimeout(timeout)
6155
}
6256
}
6357

64-
// WithRegistry set the Registry to convert custom type to mongo primitive type more easily.
65-
func WithRegistry(registerType ...RegisterType) Option {
58+
// WithTypeCodec registers TypeCodecs to convert custom types.
59+
func WithTypeCodec(typeCodecs ...TypeCodec) Option {
6660
return func(opts *options) {
6761
registry := bson.NewRegistry()
68-
for _, v := range registerType {
62+
for _, v := range typeCodecs {
6963
registry.RegisterTypeEncoder(v.ValueType, v.Encoder)
7064
registry.RegisterTypeDecoder(v.ValueType, v.Decoder)
7165
}
7266
opts.SetRegistry(registry)
7367
}
7468
}
69+
70+
func defaultTimeoutOption() Option {
71+
return func(opts *options) {
72+
opts.SetTimeout(defaultTimeout)
73+
}
74+
}

core/stores/mon/options_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,16 @@ func TestWithRegistryForTimestampRegisterType(t *testing.T) {
7979
return nil
8080
}
8181

82-
registerType := []RegisterType{
82+
codecs := []TypeCodec{
8383
{
8484
ValueType: reflect.TypeOf(time.Time{}),
8585
Encoder: mongoDateTimeEncoder,
8686
Decoder: mongoDateTimeDecoder,
8787
},
8888
}
89-
WithRegistry(registerType...)(opts)
89+
WithTypeCodec(codecs...)(opts)
9090

91-
for _, v := range registerType {
91+
for _, v := range codecs {
9292
// Validate Encoder
9393
enc, err := opts.Registry.LookupEncoder(v.ValueType)
9494
if err != nil {

tools/goctl/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ LABEL org.opencontainers.image.description="A cloud-native Go microservices fram
3535
LABEL org.opencontainers.image.licenses="MIT"
3636
LABEL org.opencontainers.image.source="https://github.com/zeromicro/go-zero"
3737
LABEL org.opencontainers.image.title="goctl (cli)"
38-
LABEL org.opencontainers.image.version="v1.6.0"
38+
LABEL org.opencontainers.image.version="v1.6.2"
3939

4040
ENTRYPOINT ["/usr/local/bin/goctl"]

tools/goctl/test/integration/model/mongo/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.21-alpine
1+
FROM golang:1.22-alpine
22

33
ENV TZ Asia/Shanghai
44
ENV GOPROXY https://goproxy.cn,direct

0 commit comments

Comments
 (0)