mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-22 13:37:10 +00:00
all: rename variables with lowercase-l/uppercase-I
See http://go/no-ell Signed-off-by: Alex Chan <alexc@tailscale.com> Updates #cleanup Change-Id: I8c976b51ce7a60f06315048b1920516129cc1d5d
This commit is contained in:
@@ -32,20 +32,20 @@ func TestPointAnonymize(t *testing.T) {
|
||||
last := geo.MakePoint(llat, 0)
|
||||
cur := geo.MakePoint(lat, 0)
|
||||
anon := cur.Quantize()
|
||||
switch l, g, err := anon.LatLng(); {
|
||||
switch latlng, g, err := anon.LatLng(); {
|
||||
case err != nil:
|
||||
t.Fatal(err)
|
||||
case lat == southPole:
|
||||
// initialize llng, to the first snapped longitude
|
||||
llat = l
|
||||
llat = latlng
|
||||
goto Lng
|
||||
case g != 0:
|
||||
t.Fatalf("%v is west or east of %v", anon, last)
|
||||
case l < llat:
|
||||
case latlng < llat:
|
||||
t.Fatalf("%v is south of %v", anon, last)
|
||||
case l == llat:
|
||||
case latlng == llat:
|
||||
continue
|
||||
case l > llat:
|
||||
case latlng > llat:
|
||||
switch dist, err := last.DistanceTo(anon); {
|
||||
case err != nil:
|
||||
t.Fatal(err)
|
||||
@@ -55,7 +55,7 @@ func TestPointAnonymize(t *testing.T) {
|
||||
t.Logf("lat=%v last=%v cur=%v anon=%v", lat, last, cur, anon)
|
||||
t.Fatalf("%v is too close to %v", anon, last)
|
||||
default:
|
||||
llat = l
|
||||
llat = latlng
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,14 +65,14 @@ func TestPointAnonymize(t *testing.T) {
|
||||
last := geo.MakePoint(llat, llng)
|
||||
cur := geo.MakePoint(lat, lng)
|
||||
anon := cur.Quantize()
|
||||
switch l, g, err := anon.LatLng(); {
|
||||
switch latlng, g, err := anon.LatLng(); {
|
||||
case err != nil:
|
||||
t.Fatal(err)
|
||||
case lng == dateLine:
|
||||
// initialize llng, to the first snapped longitude
|
||||
llng = g
|
||||
continue
|
||||
case l != llat:
|
||||
case latlng != llat:
|
||||
t.Fatalf("%v is north or south of %v", anon, last)
|
||||
case g != llng:
|
||||
const tolerance = geo.MinSeparation * 0x1p-9
|
||||
|
||||
@@ -167,11 +167,11 @@ func (k DiscoPublic) String() string {
|
||||
}
|
||||
|
||||
// Compare returns an integer comparing DiscoPublic k and l lexicographically.
|
||||
// The result will be 0 if k == l, -1 if k < l, and +1 if k > l. This is useful
|
||||
// for situations requiring only one node in a pair to perform some operation,
|
||||
// e.g. probing UDP path lifetime.
|
||||
func (k DiscoPublic) Compare(l DiscoPublic) int {
|
||||
return bytes.Compare(k.k[:], l.k[:])
|
||||
// The result will be 0 if k == other, -1 if k < other, and +1 if k > other.
|
||||
// This is useful for situations requiring only one node in a pair to perform
|
||||
// some operation, e.g. probing UDP path lifetime.
|
||||
func (k DiscoPublic) Compare(other DiscoPublic) int {
|
||||
return bytes.Compare(k.k[:], other.k[:])
|
||||
}
|
||||
|
||||
// AppendText implements encoding.TextAppender.
|
||||
|
||||
@@ -45,36 +45,36 @@ func ListWithOpts[T ImmutableType](opts ...Options) List[T] {
|
||||
// SetValue configures the preference with the specified value.
|
||||
// It fails and returns [ErrManaged] if p is a managed preference,
|
||||
// and [ErrReadOnly] if p is a read-only preference.
|
||||
func (l *List[T]) SetValue(val []T) error {
|
||||
return l.preference.SetValue(cloneSlice(val))
|
||||
func (ls *List[T]) SetValue(val []T) error {
|
||||
return ls.preference.SetValue(cloneSlice(val))
|
||||
}
|
||||
|
||||
// SetManagedValue configures the preference with the specified value
|
||||
// and marks the preference as managed.
|
||||
func (l *List[T]) SetManagedValue(val []T) {
|
||||
l.preference.SetManagedValue(cloneSlice(val))
|
||||
func (ls *List[T]) SetManagedValue(val []T) {
|
||||
ls.preference.SetManagedValue(cloneSlice(val))
|
||||
}
|
||||
|
||||
// View returns a read-only view of l.
|
||||
func (l *List[T]) View() ListView[T] {
|
||||
return ListView[T]{l}
|
||||
func (ls *List[T]) View() ListView[T] {
|
||||
return ListView[T]{ls}
|
||||
}
|
||||
|
||||
// Clone returns a copy of l that aliases no memory with l.
|
||||
func (l List[T]) Clone() *List[T] {
|
||||
res := ptr.To(l)
|
||||
if v, ok := l.s.Value.GetOk(); ok {
|
||||
func (ls List[T]) Clone() *List[T] {
|
||||
res := ptr.To(ls)
|
||||
if v, ok := ls.s.Value.GetOk(); ok {
|
||||
res.s.Value.Set(append(v[:0:0], v...))
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
// Equal reports whether l and l2 are equal.
|
||||
func (l List[T]) Equal(l2 List[T]) bool {
|
||||
if l.s.Metadata != l2.s.Metadata {
|
||||
func (ls List[T]) Equal(l2 List[T]) bool {
|
||||
if ls.s.Metadata != l2.s.Metadata {
|
||||
return false
|
||||
}
|
||||
v1, ok1 := l.s.Value.GetOk()
|
||||
v1, ok1 := ls.s.Value.GetOk()
|
||||
v2, ok2 := l2.s.Value.GetOk()
|
||||
if ok1 != ok2 {
|
||||
return false
|
||||
|
||||
@@ -487,31 +487,31 @@ func TestItemView(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestListView(t *testing.T) {
|
||||
l := ListOf([]int{4, 8, 15, 16, 23, 42}, ReadOnly)
|
||||
ls := ListOf([]int{4, 8, 15, 16, 23, 42}, ReadOnly)
|
||||
|
||||
lv := l.View()
|
||||
lv := ls.View()
|
||||
checkIsSet(t, lv, true)
|
||||
checkIsManaged(t, lv, false)
|
||||
checkIsReadOnly(t, lv, true)
|
||||
checkValue(t, lv, views.SliceOf(l.Value()))
|
||||
checkValueOk(t, lv, views.SliceOf(l.Value()), true)
|
||||
checkValue(t, lv, views.SliceOf(ls.Value()))
|
||||
checkValueOk(t, lv, views.SliceOf(ls.Value()), true)
|
||||
|
||||
l2 := *lv.AsStruct()
|
||||
checkEqual(t, l, l2, true)
|
||||
checkEqual(t, ls, l2, true)
|
||||
}
|
||||
|
||||
func TestStructListView(t *testing.T) {
|
||||
l := StructListOf([]*TestBundle{{Name: "E1"}, {Name: "E2"}}, ReadOnly)
|
||||
ls := StructListOf([]*TestBundle{{Name: "E1"}, {Name: "E2"}}, ReadOnly)
|
||||
|
||||
lv := StructListViewOf(&l)
|
||||
lv := StructListViewOf(&ls)
|
||||
checkIsSet(t, lv, true)
|
||||
checkIsManaged(t, lv, false)
|
||||
checkIsReadOnly(t, lv, true)
|
||||
checkValue(t, lv, views.SliceOfViews(l.Value()))
|
||||
checkValueOk(t, lv, views.SliceOfViews(l.Value()), true)
|
||||
checkValue(t, lv, views.SliceOfViews(ls.Value()))
|
||||
checkValueOk(t, lv, views.SliceOfViews(ls.Value()), true)
|
||||
|
||||
l2 := *lv.AsStruct()
|
||||
checkEqual(t, l, l2, true)
|
||||
checkEqual(t, ls, l2, true)
|
||||
}
|
||||
|
||||
func TestStructMapView(t *testing.T) {
|
||||
|
||||
@@ -33,20 +33,20 @@ func StructListWithOpts[T views.Cloner[T]](opts ...Options) StructList[T] {
|
||||
// SetValue configures the preference with the specified value.
|
||||
// It fails and returns [ErrManaged] if p is a managed preference,
|
||||
// and [ErrReadOnly] if p is a read-only preference.
|
||||
func (l *StructList[T]) SetValue(val []T) error {
|
||||
return l.preference.SetValue(deepCloneSlice(val))
|
||||
func (ls *StructList[T]) SetValue(val []T) error {
|
||||
return ls.preference.SetValue(deepCloneSlice(val))
|
||||
}
|
||||
|
||||
// SetManagedValue configures the preference with the specified value
|
||||
// and marks the preference as managed.
|
||||
func (l *StructList[T]) SetManagedValue(val []T) {
|
||||
l.preference.SetManagedValue(deepCloneSlice(val))
|
||||
func (ls *StructList[T]) SetManagedValue(val []T) {
|
||||
ls.preference.SetManagedValue(deepCloneSlice(val))
|
||||
}
|
||||
|
||||
// Clone returns a copy of l that aliases no memory with l.
|
||||
func (l StructList[T]) Clone() *StructList[T] {
|
||||
res := ptr.To(l)
|
||||
if v, ok := l.s.Value.GetOk(); ok {
|
||||
func (ls StructList[T]) Clone() *StructList[T] {
|
||||
res := ptr.To(ls)
|
||||
if v, ok := ls.s.Value.GetOk(); ok {
|
||||
res.s.Value.Set(deepCloneSlice(v))
|
||||
}
|
||||
return res
|
||||
@@ -56,11 +56,11 @@ func (l StructList[T]) Clone() *StructList[T] {
|
||||
// If the template type T implements an Equal(T) bool method, it will be used
|
||||
// instead of the == operator for value comparison.
|
||||
// It panics if T is not comparable.
|
||||
func (l StructList[T]) Equal(l2 StructList[T]) bool {
|
||||
if l.s.Metadata != l2.s.Metadata {
|
||||
func (ls StructList[T]) Equal(l2 StructList[T]) bool {
|
||||
if ls.s.Metadata != l2.s.Metadata {
|
||||
return false
|
||||
}
|
||||
v1, ok1 := l.s.Value.GetOk()
|
||||
v1, ok1 := ls.s.Value.GetOk()
|
||||
v2, ok2 := l2.s.Value.GetOk()
|
||||
if ok1 != ok2 {
|
||||
return false
|
||||
@@ -105,8 +105,8 @@ type StructListView[T views.ViewCloner[T, V], V views.StructView[T]] struct {
|
||||
|
||||
// StructListViewOf returns a read-only view of l.
|
||||
// It is used by [tailscale.com/cmd/viewer].
|
||||
func StructListViewOf[T views.ViewCloner[T, V], V views.StructView[T]](l *StructList[T]) StructListView[T, V] {
|
||||
return StructListView[T, V]{l}
|
||||
func StructListViewOf[T views.ViewCloner[T, V], V views.StructView[T]](ls *StructList[T]) StructListView[T, V] {
|
||||
return StructListView[T, V]{ls}
|
||||
}
|
||||
|
||||
// Valid reports whether the underlying [StructList] is non-nil.
|
||||
|
||||
@@ -31,14 +31,14 @@ func StructMapWithOpts[K MapKeyType, V views.Cloner[V]](opts ...Options) StructM
|
||||
// SetValue configures the preference with the specified value.
|
||||
// It fails and returns [ErrManaged] if p is a managed preference,
|
||||
// and [ErrReadOnly] if p is a read-only preference.
|
||||
func (l *StructMap[K, V]) SetValue(val map[K]V) error {
|
||||
return l.preference.SetValue(deepCloneMap(val))
|
||||
func (m *StructMap[K, V]) SetValue(val map[K]V) error {
|
||||
return m.preference.SetValue(deepCloneMap(val))
|
||||
}
|
||||
|
||||
// SetManagedValue configures the preference with the specified value
|
||||
// and marks the preference as managed.
|
||||
func (l *StructMap[K, V]) SetManagedValue(val map[K]V) {
|
||||
l.preference.SetManagedValue(deepCloneMap(val))
|
||||
func (m *StructMap[K, V]) SetManagedValue(val map[K]V) {
|
||||
m.preference.SetManagedValue(deepCloneMap(val))
|
||||
}
|
||||
|
||||
// Clone returns a copy of m that aliases no memory with m.
|
||||
|
||||
Reference in New Issue
Block a user