Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nil check for RNDSupporter #485

Merged
merged 1 commit into from
Nov 30, 2021
Merged

Fix nil check for RNDSupporter #485

merged 1 commit into from
Nov 30, 2021

Conversation

fhofherr
Copy link
Contributor

@fhofherr fhofherr commented Nov 30, 2021

The initial implementation suffered from Go's slightly peculiar handling
of nil interfaces.

Basically if a variable of an interface type gets assigned a pointer to
a nil value, the variable is not nil:

var rdns hcloud.RDNSSupporter

// returns nil as first return value
rdns, _, err = client.Server.GetByID(id)
if rnds == nil {
    // Never reached as rdns is not nil.
}

See also https://go.dev/doc/faq#nil_error

Fixes #482

The initial implementation suffered from Go's slightly peculiar handling
of nil interfaces.

Basically if a variable of an interface type gets assigned a pointer to
a nil value, the variable is not nil:

    var rdns hcloud.RDNSSupporter

    // returns nil as first return value
    rdns, _, err = client.Server.GetByID(id)
    if rnds == nil {
        // Never reached as rdns is not nil.
    }

See also https://go.dev/doc/faq#nil_error

Fixes #482
@fhofherr fhofherr merged commit 5c4e612 into master Nov 30, 2021
@LKaemmerling LKaemmerling deleted the 482-rdns-crash branch April 8, 2022 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Error: The terraform-provider-hcloud_v1.32.1 plugin crashed!
2 participants