mirror of
https://github.com/k3s-io/k3s.git
synced 2026-02-16 00:58:29 -05:00
Move the `ipv4` and `ipv6` constants to their own constant declaration. This ensures that the `iota` expression for the `ipv4` constant evaluates to 0, not some arbitrary value. (`iota` evaluates to N for the Nth constant in the constant declaration; see <https://go.dev/ref/spec#Iota>.) This is also more idiomatic, which improves readability. Also switch from incremental integers to bit flags, and use bitwise operators for checking. This is more idiomatic (the integer is treated like a set of booleans), it avoids some code duplication, and it is necessary to avoid ambiguity. Consider the following: const ( ipv4 = iota ipv6 ) In the above, `ipv4` would have the value 0 and `ipv6` would have the value 1. This would make it impossible to distinguish an IPv6-only stack from a dual-stack configuration because `ipv6` would equal `ipv4 + ipv6`. With bit flags this problem doesn't exist. And put the integer holding the bit flags in a custom type with convenience methods to improve readability. Signed-off-by: Richard Hansen <rhansen@rhansen.org> |
||
|---|---|---|
| .. | ||
| config | ||
| containerd | ||
| cri | ||
| cridockerd | ||
| flannel | ||
| https | ||
| loadbalancer | ||
| netpol | ||
| proxy | ||
| syssetup | ||
| templates | ||
| tunnel | ||
| util | ||
| run.go | ||
| run_linux.go | ||
| run_test.go | ||
| run_windows.go | ||