-
Notifications
You must be signed in to change notification settings - Fork 30
Support for GuestOS ID / Family #97
base: master
Are you sure you want to change the base?
Conversation
|
|
||
| package v1alpha1 | ||
|
|
||
| // VirtualMachineGuestOSDescriptor is used to specify information about the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accidental deletion of text?
|
|
||
| const ( | ||
| VirtualMachineGuestOSFamilyWindows VirtualMachineGuestOSFamily = "windowsGuest" | ||
| VirtualMachineGuestOSFamilyLinux = "linuxGuest" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we also need to specify VirtualMachineGuestOSFamily type for all these consts, or is this Golang magic that automatically assigns them the types? Either way, I would vote for being explicit in the name of readability. (Same for Guest OS Identifiers)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not. I actually think repeating it makes it harder to follow. Go supports implicit typing in const blocks by referring to the last, non-empty, explicit type in that local const block. It is how iota and enums work in Go.
I'm tired of you being right so much lately 😃 The above is what I was going to say, and then I decided to triple-check. It turns out all the blogs I've ever read about iota get typing wrong. The above language spec refrence never states that types are implicit from the previous, non-empty type in the local const block. I even verified this in this Go playground:
package main
import "fmt"
type myEnumType string
const (
typedHello myEnumType = "hello"
typedWorld = "world"
)
const (
untypedHello = "hello"
untypedWorld = "world"
)
func main() {
fmt.Printf("%[1]T=%[1]s\n", typedHello)
fmt.Printf("%[1]T=%[1]s\n", typedWorld)
fmt.Printf("%[1]T=%[1]s\n", untypedHello)
fmt.Printf("%[1]T=%[1]s\n", untypedWorld)
}I expected the first two lines of output to indicate the type was main.myEnumType, but...
main.myEnumType=hello
string=world
string=hello
string=worldSo yeah, I'll add it. Obviously 😃
p.s. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:-D
I actually tried this in playground by checking the type of two consts, before leaving the comment. I still thought you knew something that I didn't about Golang internals (as you often do).
This patch adds support for specifying the guest operating system's ID and family.
dc9e91b to
fe7838f
Compare
This patch adds support for specifying the guest operating system's ID and family.