Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsannm committed Dec 7, 2022
1 parent 86649e0 commit 08970b7
Show file tree
Hide file tree
Showing 23 changed files with 224 additions and 160 deletions.
15 changes: 15 additions & 0 deletions cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,30 @@ wd=$(pwd)

cd "$wd"/contrib || exit
go mod tidy
go fmt ./...
go vet ./...

cd "$wd"/kit || exit
go mod tidy
go fmt ./...
go vet ./...

cd "$wd"/std/clusters/rediscluster || exit
go mod tidy
go fmt ./...
go vet ./...

cd "$wd"/std/gateways/fasthttp || exit
go mod tidy
go fmt ./...
go vet ./...

cd "$wd"/std/gateways/fastws || exit
go mod tidy
go fmt ./...
go vet ./...

cd "$wd"/std/gateways/silverhttp || exit
go mod tidy
go fmt ./...
go vet ./...
11 changes: 5 additions & 6 deletions contrib/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ module github.com/clubpay/ronykit/contrib
go 1.19

require (
github.com/clubpay/ronykit/kit v0.9.9
github.com/clubpay/ronykit/std/gateways/fasthttp v0.0.0-20221105160236-d76312620245
github.com/clubpay/ronykit/kit v0.9.14
github.com/clubpay/ronykit/std/gateways/fasthttp v0.9.12
github.com/go-openapi/spec v0.20.7
github.com/goccy/go-json v0.9.11
github.com/goccy/go-json v0.10.0
go.opentelemetry.io/contrib/propagators/b3 v1.11.1
go.opentelemetry.io/otel v1.11.1
go.opentelemetry.io/otel/trace v1.11.1
go.opentelemetry.io/otel v1.11.2
go.opentelemetry.io/otel/trace v1.11.2
)

require (
Expand All @@ -24,7 +24,6 @@ require (
github.com/jedib0t/go-pretty/v6 v6.4.2 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.15.12 // indirect
github.com/kr/pretty v0.2.1 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/rivo/uniseg v0.4.2 // indirect
Expand Down
31 changes: 15 additions & 16 deletions contrib/go.sum
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/clubpay/ronykit/kit v0.9.9 h1:wXkz5dlm+uV7JyMj9sVXpTj637twQROb0G7BCXHIYog=
github.com/clubpay/ronykit/kit v0.9.9/go.mod h1:/2CHUac3Pz+PFMxwHJTR1+dxwWhv7YZjBflcTOk+1JE=
github.com/clubpay/ronykit/std/gateways/fasthttp v0.0.0-20221105160236-d76312620245 h1:4RFY4mLYpLniFV8GNY9znVYaG11CpfKDfRd4hlEt2G8=
github.com/clubpay/ronykit/std/gateways/fasthttp v0.0.0-20221105160236-d76312620245/go.mod h1:Zou8dVPmUxYINHkqfL/rjX6cAbG40D9J68g5Sp+DNnQ=
github.com/clubpay/ronykit/kit v0.9.14 h1:ezkPLCTsVN3nPHqXxmJYcVaMsif60F98WiTLzY2fJhk=
github.com/clubpay/ronykit/kit v0.9.14/go.mod h1:OmB4inXkJNKrY3w6D5zhORGGkIfCTb5A7NaRkeEoMok=
github.com/clubpay/ronykit/std/gateways/fasthttp v0.9.12 h1:h/aC4To8JdfI+tRaRkJheRxMtxPpjezUPtYejGbKKMs=
github.com/clubpay/ronykit/std/gateways/fasthttp v0.9.12/go.mod h1:yGN173DrouyFMmudELPY3M3zMpTROMDs+9TeDa4UdRs=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
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=
Expand All @@ -26,8 +26,8 @@ github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh
github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ=
github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g=
github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
github.com/goccy/go-json v0.9.11 h1:/pAaQDLHEoCq/5FFmSKBswWmK6H0e8g4159Kc/X/nqk=
github.com/goccy/go-json v0.9.11/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/goccy/go-json v0.10.0 h1:mXKd9Qw4NuzShiRlOXKews24ufknHO7gx30lsDyokKA=
github.com/goccy/go-json v0.10.0/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/goccy/go-reflect v1.2.0 h1:O0T8rZCuNmGXewnATuKYnkL0xm6o8UNOJZd/gOkb9ms=
github.com/goccy/go-reflect v1.2.0/go.mod h1:n0oYZn8VcV2CkWTxi8B9QjkCoq6GTtCEdfmR66YhFtE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
Expand All @@ -41,7 +41,6 @@ github.com/klauspost/compress v1.15.12 h1:YClS/PImqYbn+UILDnqxQCZ3RehC9N318SU3kE
github.com/klauspost/compress v1.15.12/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
Expand All @@ -55,8 +54,8 @@ github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/onsi/ginkgo/v2 v2.2.0 h1:3ZNA3L1c5FYDFTTxbFeVGGD8jYvjYauHD30YgLxVsNI=
github.com/onsi/gomega v1.21.1 h1:OB/euWYIExnPBohllTicTHmGTrMaqJ67nIu80j0/uEM=
github.com/onsi/ginkgo/v2 v2.5.1 h1:auzK7OI497k6x4OvWq+TKAcpcSAlod0doAH72oIN0Jw=
github.com/onsi/gomega v1.24.1 h1:KORJXNNTzJXzu4ScJWssJfJMnJ+2QJqhoQSRwNlze9E=
github.com/pkg/profile v1.6.0/go.mod h1:qBsxPvzyUincmltOk6iyRVxHYg4adc0OFOv72ZdLa18=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand All @@ -71,7 +70,7 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.4/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasthttp v1.41.0 h1:zeR0Z1my1wDHTRiamBCXVglQdbUwgb9uWG3k1HQz6jY=
Expand All @@ -80,14 +79,14 @@ github.com/valyala/tcplisten v1.0.0 h1:rBHj/Xf+E1tRGZyWIWwJDiRY0zc1Js+CV5DqwacVS
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
go.opentelemetry.io/contrib/propagators/b3 v1.11.1 h1:icQ6ttRV+r/2fnU46BIo/g/mPu6Rs5Ug8Rtohe3KqzI=
go.opentelemetry.io/contrib/propagators/b3 v1.11.1/go.mod h1:ECIveyMXgnl4gorxFcA7RYjJY/Ql9n20ubhbfDc3QfA=
go.opentelemetry.io/otel v1.11.1 h1:4WLLAmcfkmDk2ukNXJyq3/kiz/3UzCaYq6PskJsaou4=
go.opentelemetry.io/otel v1.11.1/go.mod h1:1nNhXBbWSD0nsL38H6btgnFN2k4i0sNLHNNMZMSbUGE=
go.opentelemetry.io/otel/trace v1.11.1 h1:ofxdnzsNrGBYXbP7t7zpUK281+go5rF7dvdIZXF8gdQ=
go.opentelemetry.io/otel/trace v1.11.1/go.mod h1:f/Q9G7vzk5u91PhbmKbg1Qn0rzH1LJ4vbPHFGkTPtOk=
go.opentelemetry.io/otel v1.11.2 h1:YBZcQlsVekzFsFbjygXMOXSs6pialIZxcjfO/mBDmR0=
go.opentelemetry.io/otel v1.11.2/go.mod h1:7p4EUV+AqgdlNV9gL97IgUZiVR3yrFXYo53f9BM3tRI=
go.opentelemetry.io/otel/trace v1.11.2 h1:Xf7hWSF2Glv0DE3MH7fBHvtpSBsjcBUe5MYAmZM/+y0=
go.opentelemetry.io/otel/trace v1.11.2/go.mod h1:4N+yC7QEz7TTsG9BSRLNAa63eg5E06ObSbKPmxQ/pKA=
golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220906165146-f3363e06e74c h1:yKufUcDwucU5urd+50/Opbt4AYpqthk7wHpHok8f1lo=
golang.org/x/net v0.0.0-20220906165146-f3363e06e74c/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand All @@ -98,8 +97,8 @@ golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
18 changes: 16 additions & 2 deletions contrib/swagger/swagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,11 @@ func (sg *Generator) WriteToFile(filename string, services ...desc.ServiceDesc)

func (sg *Generator) WriteTo(w io.Writer, descs ...desc.ServiceDesc) error {
for _, d := range descs {
// extract the service description
s := d.Desc()

addSwaggerTag(sg.s, s)

for _, c := range s.Contracts {
c.PossibleErrors = append(c.PossibleErrors, s.PossibleErrors...)
sg.addOperation(sg.s, s.Name, c)
Expand All @@ -76,14 +79,25 @@ func (sg *Generator) addOperation(swag *spec.Swagger, serviceName string, c desc
Paths: map[string]spec.PathItem{},
}
}
var contentType string
switch c.Encoding {
case kit.JSON:
contentType = "application/json"
case kit.Proto:
contentType = "application/x-protobuf"
case kit.MSG:
contentType = "application/octet-stream"
default:
contentType = "application/json"
}

inType := reflect.Indirect(reflect.ValueOf(c.Input)).Type()
outType := reflect.Indirect(reflect.ValueOf(c.Output)).Type()
opID := c.Name
op := spec.NewOperation(opID).
WithTags(serviceName).
WithProduces("application/json").
WithConsumes("application/json").
WithProduces(contentType).
WithConsumes(contentType).
RespondsWith(
http.StatusOK,
spec.NewResponse().
Expand Down
1 change: 0 additions & 1 deletion contrib/swagger/swagger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ type testService struct{}
func (t testService) Desc() *desc.Service {
return (&desc.Service{
Name: "testService",

}).
AddContract(
desc.NewContract().
Expand Down
74 changes: 37 additions & 37 deletions contrib/swagger/tag.go
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
package swagger

import (
"reflect"
"strings"
"reflect"
"strings"
)

const (
swagTagKey = "swag"
swagSep = ";"
swagIdentSep = ":"
swagValueSep = ","
swagTagKey = "swag"
swagSep = ";"
swagIdentSep = ":"
swagValueSep = ","
)

type parsedStructTag struct {
Name string
Optional bool
PossibleValues []string
Name string
Optional bool
PossibleValues []string
}

func getParsedStructTag(tag reflect.StructTag, name string) parsedStructTag {
pst := parsedStructTag{}
nameTag := tag.Get(name)
if nameTag == "" {
return pst
}
pst := parsedStructTag{}
nameTag := tag.Get(name)
if nameTag == "" {
return pst
}

// This is a hack to remove omitempty from tags
fNameParts := strings.Split(nameTag, swagValueSep)
if len(fNameParts) > 0 {
pst.Name = strings.TrimSpace(fNameParts[0])
}
// This is a hack to remove omitempty from tags
fNameParts := strings.Split(nameTag, swagValueSep)
if len(fNameParts) > 0 {
pst.Name = strings.TrimSpace(fNameParts[0])
}

swagTag := tag.Get(swagTagKey)
parts := strings.Split(swagTag, swagSep)
for _, p := range parts {
x := strings.TrimSpace(strings.ToLower(p))
switch {
case x == "optional":
pst.Optional = true
case strings.HasPrefix(x, "enum:"):
xx := strings.SplitN(p, swagIdentSep, 2)
if len(xx) == 2 {
xx = strings.Split(xx[1], swagValueSep)
for _, v := range xx {
pst.PossibleValues = append(pst.PossibleValues, strings.TrimSpace(v))
}
}
}
}
swagTag := tag.Get(swagTagKey)
parts := strings.Split(swagTag, swagSep)
for _, p := range parts {
x := strings.TrimSpace(strings.ToLower(p))
switch {
case x == "optional":
pst.Optional = true
case strings.HasPrefix(x, "enum:"):
xx := strings.SplitN(p, swagIdentSep, 2)
if len(xx) == 2 {
xx = strings.Split(xx[1], swagValueSep)
for _, v := range xx {
pst.PossibleValues = append(pst.PossibleValues, strings.TrimSpace(v))
}
}
}
}

return pst
return pst
}
6 changes: 3 additions & 3 deletions contrib/tracekit/helpers.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package tracekit

import (
"github.com/clubpay/ronykit/kit"
"go.opentelemetry.io/otel/trace"
"github.com/clubpay/ronykit/kit"
"go.opentelemetry.io/otel/trace"
)

func Span(ctx *kit.Context) trace.Span {
return trace.SpanFromContext(ctx.Context())
return trace.SpanFromContext(ctx.Context())
}
36 changes: 18 additions & 18 deletions contrib/tracekit/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,34 @@ import "github.com/clubpay/ronykit/kit"
type Option func(cfg *config)

type config struct {
tracerName string
propagator TracePropagator
serviceName string
env string
tags map[string]string
dynTags func(ctx *kit.LimitedContext) map[string]string
tracerName string
propagator TracePropagator
serviceName string
env string
tags map[string]string
dynTags func(ctx *kit.LimitedContext) map[string]string
}

func ServiceName(name string) Option {
return func(cfg *config) {
cfg.serviceName = name
}
return func(cfg *config) {
cfg.serviceName = name
}
}

func Env(env string) Option {
return func(cfg *config) {
cfg.env = env
}
return func(cfg *config) {
cfg.env = env
}
}

func WithTags(tags map[string]string) Option {
return func(cfg *config) {
cfg.tags = tags
}
return func(cfg *config) {
cfg.tags = tags
}
}

func WithDynamicTags(f func(ctx *kit.LimitedContext) map[string]string) Option {
return func(cfg *config) {
cfg.dynTags = f
}
return func(cfg *config) {
cfg.dynTags = f
}
}
10 changes: 5 additions & 5 deletions kit/desc/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,6 @@ func (c *Contract) NamedSelector(name string, s kit.RouteSelector) *Contract {
return c.AddNamedSelector(name, s)
}

// SelectorWithName is an alias for AddNamedSelector
func (c *Contract) SelectorWithName(name string, s kit.RouteSelector) *Contract {
return c.AddNamedSelector(name, s)
}

// SetCoordinator sets a kit.EdgeSelectorFunc for this contract, to coordinate requests to
// right kit.EdgeServer instance.
func (c *Contract) SetCoordinator(f kit.EdgeSelectorFunc) *Contract {
Expand All @@ -128,6 +123,11 @@ func (c *Contract) SetCoordinator(f kit.EdgeSelectorFunc) *Contract {
return c
}

// Coordinator is an alias for SetCoordinator
func (c *Contract) Coordinator(f kit.EdgeSelectorFunc) *Contract {
return c.SetCoordinator(f)
}

// AddModifier adds a kit.ModifierFunc for this contract. Modifiers are used to modify
// the outgoing kit.Envelope just before sending to the client.
func (c *Contract) AddModifier(m kit.ModifierFunc) *Contract {
Expand Down
10 changes: 3 additions & 7 deletions kit/desc/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ func (s *Service) SetDescription(d string) *Service {
return s
}

// AddPreHandler Deprecated use AddHandler instead.
func (s *Service) AddPreHandler(h ...kit.HandlerFunc) *Service {
s.Handlers = append(s.Handlers, h...)

return s
}

// AddHandler adds handlers to run before and/or after the contract's handlers
func (s *Service) AddHandler(h ...kit.HandlerFunc) *Service {
s.Handlers = append(s.Handlers, h...)
Expand Down Expand Up @@ -92,6 +85,9 @@ func (s *Service) AddContract(contracts ...*Contract) *Service {
// AddError sets the possible errors for all the Contracts of this Service.
// Using this method is OPTIONAL, which mostly could be used by external tools such as
// Swagger or any other doc generator tools.
// NOTE: The auto-generated stub also use these errors to identifies if the response should be considered
//
// as error or successful.
func (s *Service) AddError(err kit.ErrorMessage) *Service {
s.PossibleErrors = append(
s.PossibleErrors,
Expand Down
Loading

0 comments on commit 08970b7

Please sign in to comment.