@@ -2,6 +2,7 @@ package github
22
33import (
44 "context"
5+ "errors"
56 "fmt"
67 "net/http"
78 "strconv"
@@ -82,7 +83,8 @@ func resourceGithubUserSshKeyRead(ctx context.Context, d *schema.ResourceData, m
8283 keyID := d .Get ("key_id" ).(int64 )
8384 _ , _ , err := client .Users .GetKey (ctx , keyID )
8485 if err != nil {
85- if ghErr , ok := err .(* github.ErrorResponse ); ok {
86+ var ghErr * github.ErrorResponse
87+ if errors .As (err , & ghErr ) {
8688 if ghErr .Response .StatusCode == http .StatusNotModified {
8789 return nil
8890 }
@@ -114,12 +116,13 @@ func resourceGithubUserSshKeyImport(ctx context.Context, d *schema.ResourceData,
114116
115117 keyID , err := strconv .ParseInt (d .Id (), 10 , 64 )
116118 if err != nil {
117- return nil , fmt .Errorf ("invalid SSH key ID format: %v " , err )
119+ return nil , fmt .Errorf ("invalid SSH key ID format: %w " , err )
118120 }
119121
120122 key , resp , err := client .Users .GetKey (ctx , keyID )
121123 if err != nil {
122- if ghErr , ok := err .(* github.ErrorResponse ); ok {
124+ var ghErr * github.ErrorResponse
125+ if errors .As (err , & ghErr ) {
123126 if ghErr .Response .StatusCode == http .StatusNotFound {
124127 return nil , fmt .Errorf ("SSH key with ID %d not found" , keyID )
125128 }
0 commit comments