Skip to content

Commit

Permalink
multi: Replace interface{} with 'any' alias
Browse files Browse the repository at this point in the history
  • Loading branch information
jholdstock committed Aug 18, 2023
1 parent 820f130 commit 0a38bd8
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ func (c *Client) SetVoteChoices(ctx context.Context, req types.SetVoteChoicesReq
return resp, nil
}

func (c *Client) post(ctx context.Context, path string, addr stdaddr.Address, resp, req interface{}) error {
func (c *Client) post(ctx context.Context, path string, addr stdaddr.Address, resp, req any) error {
return c.do(ctx, http.MethodPost, path, addr, resp, req)
}

func (c *Client) get(ctx context.Context, path string, resp interface{}) error {
func (c *Client) get(ctx context.Context, path string, resp any) error {
return c.do(ctx, http.MethodGet, path, nil, resp, nil)
}

func (c *Client) do(ctx context.Context, method, path string, addr stdaddr.Address, resp, req interface{}) error {
func (c *Client) do(ctx context.Context, method, path string, addr stdaddr.Address, resp, req any) error {
var reqBody io.Reader
var sig []byte

Expand Down
4 changes: 2 additions & 2 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestErrorDetails(t *testing.T) {
Log: slog.Disabled,
}

var resp interface{}
var resp any
err := client.do(context.TODO(), http.MethodGet, "", nil, &resp, nil)

testServer.Close()
Expand Down Expand Up @@ -171,7 +171,7 @@ func TestSignatureValidation(t *testing.T) {
Log: slog.Disabled,
}

var resp interface{}
var resp any
err := client.do(context.TODO(), http.MethodGet, "", nil, &resp, nil)

testServer.Close()
Expand Down
2 changes: 1 addition & 1 deletion rpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Caller interface {
// Args provides positional parameters for the call.
// Res must be a pointer to a struct, slice, or map type to unmarshal
// a result (if any), or nil if no result is needed.
Call(ctx context.Context, method string, res interface{}, args ...interface{}) error
Call(ctx context.Context, method string, res any, args ...any) error
}

// client wraps a wsrpc.Client, as well as all of the connection details
Expand Down
2 changes: 1 addition & 1 deletion webapi/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (s *Server) downloadDatabaseBackup(c *gin.Context) {

// setAdminStatus stores the authentication status of the current session and
// redirects the client to GET /admin.
func (s *Server) setAdminStatus(admin interface{}, c *gin.Context) {
func (s *Server) setAdminStatus(admin any, c *gin.Context) {
session := c.MustGet(sessionKey).(*sessions.Session)
session.Values["admin"] = admin
err := session.Save(c.Request, c.Writer)
Expand Down
2 changes: 1 addition & 1 deletion webapi/webapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func (s *Server) router(cookieSecret []byte, dcrd rpc.DcrdConnect, wallets rpc.W
// sendJSONResponse serializes the provided response, signs it, and sends the
// response to the client with a 200 OK status. Returns the seralized response
// and the signature.
func (s *Server) sendJSONResponse(resp interface{}, c *gin.Context) (string, string) {
func (s *Server) sendJSONResponse(resp any, c *gin.Context) (string, string) {
dec, err := json.Marshal(resp)
if err != nil {
s.log.Errorf("JSON marshal error: %v", err)
Expand Down

0 comments on commit 0a38bd8

Please sign in to comment.