multi: Replace interface{} with 'any' alias

This commit is contained in:
jholdstock 2023-07-20 14:28:31 +01:00 committed by Jamie Holdstock
parent 820f130f59
commit 0a38bd8152
5 changed files with 8 additions and 8 deletions

View File

@ -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

View File

@ -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()
@ -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()

View File

@ -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

View File

@ -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)

View File

@ -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)