Skip to content

Commit 8f35cd3

Browse files
committed
check for err as well
1 parent 00967bc commit 8f35cd3

File tree

11 files changed

+11
-11
lines changed

11 files changed

+11
-11
lines changed

hcloud/certificate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (c *CertificateClient) GetByName(ctx context.Context, name string) (*Certif
131131
func (c *CertificateClient) Get(ctx context.Context, idOrName string) (*Certificate, *Response, error) {
132132
if id, err := strconv.ParseInt(idOrName, 10, 64); err == nil {
133133
cert, res, err := c.GetByID(ctx, id)
134-
if cert != nil {
134+
if cert != nil || err != nil {
135135
return cert, res, err
136136
}
137137
}

hcloud/firewall.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func (c *FirewallClient) GetByName(ctx context.Context, name string) (*Firewall,
129129
func (c *FirewallClient) Get(ctx context.Context, idOrName string) (*Firewall, *Response, error) {
130130
if id, err := strconv.ParseInt(idOrName, 10, 64); err == nil {
131131
fw, res, err := c.GetByID(ctx, id)
132-
if fw != nil {
132+
if fw != nil || err != nil {
133133
return fw, res, err
134134
}
135135
}

hcloud/floating_ip.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (c *FloatingIPClient) GetByName(ctx context.Context, name string) (*Floatin
130130
func (c *FloatingIPClient) Get(ctx context.Context, idOrName string) (*FloatingIP, *Response, error) {
131131
if id, err := strconv.ParseInt(idOrName, 10, 64); err == nil {
132132
ip, res, err := c.GetByID(ctx, id)
133-
if ip != nil {
133+
if ip != nil || err != nil {
134134
return ip, res, err
135135
}
136136
}

hcloud/image.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func (c *ImageClient) Get(ctx context.Context, idOrName string) (*Image, *Respon
150150
func (c *ImageClient) GetForArchitecture(ctx context.Context, idOrName string, architecture Architecture) (*Image, *Response, error) {
151151
if id, err := strconv.ParseInt(idOrName, 10, 64); err == nil {
152152
img, res, err := c.GetByID(ctx, id)
153-
if img != nil {
153+
if img != nil || err != nil {
154154
return img, res, err
155155
}
156156
}

hcloud/load_balancer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ func (c *LoadBalancerClient) GetByName(ctx context.Context, name string) (*LoadB
276276
func (c *LoadBalancerClient) Get(ctx context.Context, idOrName string) (*LoadBalancer, *Response, error) {
277277
if id, err := strconv.ParseInt(idOrName, 10, 64); err == nil {
278278
lb, res, err := c.GetByID(ctx, id)
279-
if lb != nil {
279+
if lb != nil || err != nil {
280280
return lb, res, err
281281
}
282282
}

hcloud/network.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func (c *NetworkClient) GetByName(ctx context.Context, name string) (*Network, *
120120
func (c *NetworkClient) Get(ctx context.Context, idOrName string) (*Network, *Response, error) {
121121
if id, err := strconv.ParseInt(idOrName, 10, 64); err == nil {
122122
n, res, err := c.GetByID(ctx, id)
123-
if n != nil {
123+
if n != nil || err != nil {
124124
return n, res, err
125125
}
126126
}

hcloud/placement_group.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (c *PlacementGroupClient) GetByName(ctx context.Context, name string) (*Pla
7171
func (c *PlacementGroupClient) Get(ctx context.Context, idOrName string) (*PlacementGroup, *Response, error) {
7272
if id, err := strconv.ParseInt(idOrName, 10, 64); err == nil {
7373
pg, res, err := c.GetByID(ctx, id)
74-
if pg != nil {
74+
if pg != nil || err != nil {
7575
return pg, res, err
7676
}
7777
}

hcloud/primary_ip.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ func (c *PrimaryIPClient) GetByName(ctx context.Context, name string) (*PrimaryI
210210
func (c *PrimaryIPClient) Get(ctx context.Context, idOrName string) (*PrimaryIP, *Response, error) {
211211
if id, err := strconv.ParseInt(idOrName, 10, 64); err == nil {
212212
ip, res, err := c.GetByID(ctx, id)
213-
if ip != nil {
213+
if ip != nil || err != nil {
214214
return ip, res, err
215215
}
216216
}

hcloud/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ func (c *ServerClient) GetByName(ctx context.Context, name string) (*Server, *Re
231231
func (c *ServerClient) Get(ctx context.Context, idOrName string) (*Server, *Response, error) {
232232
if id, err := strconv.ParseInt(idOrName, 10, 64); err == nil {
233233
srv, res, err := c.GetByID(ctx, id)
234-
if srv != nil {
234+
if srv != nil || err != nil {
235235
return srv, res, err
236236
}
237237
}

hcloud/ssh_key.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func (c *SSHKeyClient) GetByFingerprint(ctx context.Context, fingerprint string)
7272
func (c *SSHKeyClient) Get(ctx context.Context, idOrName string) (*SSHKey, *Response, error) {
7373
if id, err := strconv.ParseInt(idOrName, 10, 64); err == nil {
7474
sshKey, res, err := c.GetByID(ctx, id)
75-
if sshKey != nil {
75+
if sshKey != nil || err != nil {
7676
return sshKey, res, err
7777
}
7878
}

0 commit comments

Comments
 (0)