Skip to content

daemon: isOnlineFSOperationPermitted: cleanup confusing syntax#49218

Merged
vvoland merged 1 commit intomoby:masterfrom
thaJeztah:daemon_clean_syntax
Jan 7, 2025
Merged

daemon: isOnlineFSOperationPermitted: cleanup confusing syntax#49218
vvoland merged 1 commit intomoby:masterfrom
thaJeztah:daemon_clean_syntax

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah commented Jan 4, 2025

This function was using a confusing syntax because Isolation.IsDefault() and Isolation.IsHyperV() don't accept an argument. It's valid (see below), but just confusing, so let's use a more common approach.

https://go.dev/play/p/as6ILVpqbV5

package main

import "fmt"

type NameSayer string

func (f NameSayer) SayMyName() {
	fmt.Println(f)
}

func main() {
	var foo NameSayer = "my name is"
	foo.SayMyName()

	NameSayer("my name is..").SayMyName()

	// Thought SayMyName() would take no arguments? Think again!
	NameSayer.SayMyName("slim shady!")
}

While at it, also renamed the container argument as it was shadowing the container import.

- A picture of a cute animal (not mandatory but encouraged)

This function was using a confusing syntax because `Isolation.IsDefault()`
and `Isolation.IsHyperV()` don't accept an argument. It's valid (see below),
but just confusing, so let's use a more common approach.

```go
package main

import "fmt"

type NameSayer string

func (f NameSayer) SayMyName() {
	fmt.Println(f)
}

func main() {
	var foo NameSayer = "my name is"
	foo.SayMyName()

	NameSayer("my name is..").SayMyName()

	// Thought SayMyName() would take no arguments? Think again!
	NameSayer.SayMyName("slim shady!")
}
```

While at it, also renamed the `container` argument as it was shadowing
the `container` import.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah thaJeztah added status/2-code-review area/daemon Core Engine kind/refactor PR's that refactor, or clean-up code labels Jan 4, 2025
@thaJeztah thaJeztah added this to the 28.0.0 milestone Jan 4, 2025
@thaJeztah thaJeztah self-assigned this Jan 4, 2025
@thaJeztah thaJeztah requested a review from rumpl January 4, 2025 17:32
@thaJeztah
Copy link
Copy Markdown
Member Author

@rumpl LGTY? 😅

@vvoland vvoland merged commit c08f00d into moby:master Jan 7, 2025
@thaJeztah thaJeztah deleted the daemon_clean_syntax branch January 7, 2025 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/daemon Core Engine kind/refactor PR's that refactor, or clean-up code status/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants