Skip to content

Commit 6f79543

Browse files
committed
fix: perfsprint recommendations
Signed-off-by: Mike Nguyen <[email protected]>
1 parent 314dbbe commit 6f79543

File tree

8 files changed

+20
-22
lines changed

8 files changed

+20
-22
lines changed

service/grpc/binding.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ import (
2727
// AddBindingInvocationHandler appends provided binding invocation handler with its name to the service.
2828
func (s *Server) AddBindingInvocationHandler(name string, fn common.BindingInvocationHandler) error {
2929
if name == "" {
30-
return fmt.Errorf("binding name required")
30+
return errors.New("binding name required")
3131
}
3232
if fn == nil {
33-
return fmt.Errorf("binding handler required")
33+
return errors.New("binding handler required")
3434
}
3535
s.bindingHandlers[name] = fn
3636
return nil

service/grpc/health_check.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ package grpc
1515

1616
import (
1717
"context"
18-
"fmt"
18+
"errors"
1919

2020
pb "github.com/dapr/dapr/pkg/proto/runtime/v1"
2121
"github.com/dapr/go-sdk/service/common"
@@ -26,7 +26,7 @@ import (
2626
// AddHealthCheckHandler appends provided app health check handler.
2727
func (s *Server) AddHealthCheckHandler(_ string, fn common.HealthCheckHandler) error {
2828
if fn == nil {
29-
return fmt.Errorf("health check handler required")
29+
return errors.New("health check handler required")
3030
}
3131

3232
s.healthCheckHandler = fn
@@ -44,5 +44,5 @@ func (s *Server) HealthCheck(ctx context.Context, _ *emptypb.Empty) (*pb.HealthC
4444
return &pb.HealthCheckResponse{}, nil
4545
}
4646

47-
return nil, fmt.Errorf("health check handler not implemented")
47+
return nil, errors.New("health check handler not implemented")
4848
}

service/grpc/invoke.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ import (
2828
// AddServiceInvocationHandler appends provided service invocation handler with its method to the service.
2929
func (s *Server) AddServiceInvocationHandler(method string, fn cc.ServiceInvocationHandler) error {
3030
if method == "" || method == "/" {
31-
return fmt.Errorf("servie name required")
31+
return errors.New("service name required")
3232
}
3333

3434
if method[0] == '/' {
3535
method = method[1:]
3636
}
3737

3838
if fn == nil {
39-
return fmt.Errorf("invocation handler required")
39+
return errors.New("invocation handler required")
4040
}
4141
s.invokeHandlers[method] = fn
4242
return nil

service/http/binding.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ limitations under the License.
1414
package http
1515

1616
import (
17-
"fmt"
17+
"errors"
1818
"io"
1919
"net/http"
2020
"strings"
@@ -25,14 +25,14 @@ import (
2525
// AddBindingInvocationHandler appends provided binding invocation handler with its route to the service.
2626
func (s *Server) AddBindingInvocationHandler(route string, fn common.BindingInvocationHandler) error {
2727
if route == "" {
28-
return fmt.Errorf("binding route required")
28+
return errors.New("binding route required")
2929
}
3030
if fn == nil {
31-
return fmt.Errorf("binding handler required")
31+
return errors.New("binding handler required")
3232
}
3333

3434
if !strings.HasPrefix(route, "/") {
35-
route = fmt.Sprintf("/%s", route)
35+
route = "/" + route
3636
}
3737

3838
s.mux.Handle(route, optionsHandler(http.HandlerFunc(

service/http/health_check.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ limitations under the License.
1414
package http
1515

1616
import (
17-
"fmt"
17+
"errors"
1818
"net/http"
1919
"strings"
2020

@@ -24,11 +24,11 @@ import (
2424
// AddHealthCheckHandler appends provided app health check handler.
2525
func (s *Server) AddHealthCheckHandler(route string, fn common.HealthCheckHandler) error {
2626
if fn == nil {
27-
return fmt.Errorf("health check handler required")
27+
return errors.New("health check handler required")
2828
}
2929

3030
if !strings.HasPrefix(route, "/") {
31-
route = fmt.Sprintf("/%s", route)
31+
route = "/" + route
3232
}
3333

3434
s.mux.Handle(route, optionsHandler(http.HandlerFunc(

service/http/invoke.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ limitations under the License.
1414
package http
1515

1616
import (
17-
"fmt"
17+
"errors"
1818
"io"
1919
"net/http"
2020
"strings"
@@ -27,11 +27,11 @@ import (
2727
// AddServiceInvocationHandler appends provided service invocation handler with its route to the service.
2828
func (s *Server) AddServiceInvocationHandler(route string, fn common.ServiceInvocationHandler) error {
2929
if route == "" || route == "/" {
30-
return fmt.Errorf("service route required")
30+
return errors.New("service route required")
3131
}
3232

3333
if fn == nil {
34-
return fmt.Errorf("invocation handler required")
34+
return errors.New("invocation handler required")
3535
}
3636

3737
if !strings.HasPrefix(route, "/") {

service/http/scheduling.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@ package http
22

33
import (
44
"errors"
5-
"fmt"
65

76
"github.com/dapr/go-sdk/service/common"
87
)
98

109
func (s *Server) AddJobEventHandler(name string, fn common.JobEventHandler) error {
1110
if name == "" {
12-
return fmt.Errorf("job event name required")
11+
return errors.New("job event name required")
1312
}
1413
if fn == nil {
15-
return fmt.Errorf("job event handler required")
14+
return errors.New("job event handler required")
1615
}
1716

1817
return errors.New("handling http scheduling requests has not been implemented in this sdk")

service/internal/topicregistrar.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package internal
22

33
import (
44
"errors"
5-
"fmt"
65

76
"github.com/dapr/go-sdk/service/common"
87
)
@@ -27,7 +26,7 @@ func (m TopicRegistrar) AddSubscription(sub *common.Subscription, fn common.Topi
2726
return errors.New("pub/sub name required")
2827
}
2928
if fn == nil {
30-
return fmt.Errorf("topic handler required")
29+
return errors.New("topic handler required")
3130
}
3231

3332
var key string

0 commit comments

Comments
 (0)